Flexible Color Assignment in Houdini and Redshift
How do you assign random colors from a specific set to objects and keep the setup flexible for changes with Houdini and Redshift?
Let’s say we have several plastic cups in a scene and 4 specific colors from a client.
- Create a class attribute with a connectivity node (you can name it whatever you like).
- Promote it to the vertex level with an attribute promote.
- In the shader tree, use an RS Integer User Data node to bring in the attribute named “class” (or any other name that you gave it earlier).
- Connect it to an RS Jitter node (name it “max_variations_01”) and select “User Data ID” in Input ID Mode. In “integer jitter,” set the min to 0 and the max to 3, so we will have 4 variations. With this node, we only control the number of variations.
- Create another RS Jitter node (name it “lightness_range_01”). We will use it to create lightness variations. Keep the color to black and set Saturation Variation Max to 0. Now, with the Value Seed, you can control the randomness.
- Create an RS Color Ramp (name it “recolor_01”) with 4 colors from your client and set the interpolation to constant.
- After adjusting the seed on the “lightness_range_01” node, you will need to move the colors a little bit on “recolor_01” so each of them will end up in a range generated by “lightness_range_01.”
Another thing that you can do is to offset UVs for each object. So when you add textures for roughness, they will not repeat obviously. To do this, after the connectivity node, add an attribute wrangle node (Run over Vertices) with this:
@uv.x+=rand(@class);
Before:
After: