Demonstrating surfacing instances uniquely
Instances can be uniquely shaded using Nodes in the Surface Editor, whether just a simple color change, or completely different materials. This section deals with the options you have at your disposal.
Random Colors (‘Fixed Random’ Output)
Creating random coloring of instances is done using the Instance Info node, connecting the Fixed Random output into a Gradient node, and then into any color channel. Setting keys at 0 and 1 on the gradient represents the total number of instances. An easy way to understand this is to think of key 0 as being the first instance, and key 1 being the last. Every instance in between is then given a randomly picked color from the 0 - 1 gradient range. This is useful so that even if you change the number of instances in the Instance Generator, all instances will be included in the 0 - 1 range.
The colors are picked at render time, and remain associated with the instance they were assigned to for the life of the instance. However if you change the number of instances, then the coloring may change as there are now more instances to consider.
You can of course add as many gradient keys as you like to introduce more random colors
Setting Up Random Coloring
- Once you have instances setup, open the Surface Editor and click Edit Node Graph.
- Add the following nodes to your flow:
- Spot > Instance Info
Gradient > Gradient
(You can add these by typing the first few letters in the search field)
- Connect Fixed Random on the Instance Info node to Input on the Gradient node, and then Color on the Gradient node to the Color input on the Surface node.
- Open the options for the Gradient node and add gradient keys at several positions in the gradient by clicking. Choose a different color for each key.
When rendered, instances will now have random choices of the colors you set in the Gradient node.
Absolute Coloring (ID Index Output)
The ID Index output on the Instance Info node allows you to specify exact colors for each instance using gradient keys at set values, whole numbers that correspond to the instance ID number. Only keys set at whole numbers will be correctly assigned, as instance IDs are integer values, for example, setting a key a 1.5 will not change the color, it would have to be set to 2 to have any effect.
Setting a gradient key to Stepped mode will continue the previous key color until you specify a new one. You can also blend between colors by setting the gradient key to either Linear, Hermite or Bezier modes.