Using an ICE attribute to drive a procedural texture


Here’s a simple example of using an ICE attribute to drive a procedural texture. In this case, I’m using a random integer to drive the number of repeats of a checkerboard:

randomized_checker

To set it up, I ran this script to programmatically add an ICE attribute. Unfortunately, I found I had to add an ICE tree to get the attribute to show up in the render tree.

import random

si = Application
    
for o in si.Selection:
	# Long, Single, Singleton
	a = o.ActivePrimitive.Geometry.AddICEAttribute("_random", 2, 1, 1  )
	a.DataArray = [ (random.randint(1,8))]
	si.ApplyOp("ICETree", o, "siNode", "", "", 0)

Then in the render tree I used Integer Attribute node to get the attribute value. This same material is applied to every cube in my example.
randomized_checker_mat

And if you wanted to update the ICE attribute later, eg increase the range of random values, you could do something like this:

import random

si = Application
    
for o in si.Selection:
	a = o.ActivePrimitive.Geometry.ICEAttributes("_random")
	a.DataArray = [ (random.randint(1,12))]

One thought on “Using an ICE attribute to drive a procedural texture

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s