Caffeine Abuse - The Blog

Assigning different textures to the same geometry-instances in ICE

While you can’t assign different materials to the same geometry instances per se, you can use attributes from the pointclod to achieve the same result. Start by open the scene multiple_textures.scn from this issues CD. Select the PointCloud and press [Alt] + [9] to open an ICE Tree. With the pointcloud and the instanced geometry already in place, the only thing left to add is a random color. Get a Randomize Color by Gradient node and connect it to the Color input of the Emit from Surface node. Open the Randomize Color by Gradient PPG and change gradient to match the screenshot.

Select the can object and from the Get > Material menu choose Blinn to apply a material and then press [7] to open a Render Tree. While each particle has a random color assigned to it, the color information is not automatically passed on to the material. From the Attributes category get a Color node. Open its PPG and change the Attribute to Color.

From the Images Processing category get a RGBA Keyer and open its PPG. Set the both the Minimum and Maximum threshold color to R:0, G:1, B:0 (pure green). Set the Color if in rage to white (R:1 G:1 B:1), and the Color if outside range to black (R:0 G:0 B:0). This will create a mask where all the green particles will be output as white and everything else as black. Duplicate the RGBA Keyer node and change the Min and Max threshold color to pure blue (R:0, G:0, B:1).

In the Mixers category get a Mix 8 Colors node. Open its PPG and check the In Use checkbox for the Layer 2. Connect the Attribute Color node to the input of each of the RGBA keyer nodes. Connect the first RGBA keyer to the weight1 input of the Mix_8colors node and the second RGBA keyer to the weight2 input. Connect the Mix_8colors node to the diffuse and ambient input of the Blinn node. Add three image nodes, each with a separate texture, and connect the first to the base_color input of the Mix_8colors node, the second to the color1 input and the third image node to the color2 input. You’re now using three different textures on the same geometry-instances.

The project files used in this tutorial can be found at:
http://www.redi-vivus.com/Caffeineabuse/ICE_Textured_Instances.zip

Textured_Instances_img01
Using blocks of solid colors rather than the smooth gradient is a quick and efficient way to define random colors.
Textured_Instances_img02
The color information is then used in the Render Tree to assign a different texture to each of the colors defined in the gradient.

Quick tip
To change the balance between of the different colors (textures) simply change the markers position on the gradient.

2 Comments

  1. April 25, 2010

    had this problem..specially with an feather system where i wanted to implement different texture through an instancing system of ice thanks for sharing.!! m/

  2. May 14, 2010

    Many thanks for the tutorials!!!!
    For this purpose you can also use a BA_Color_switcher, which is a little bit simpler than this solution.