Table Of Contents
Overview
The Material Switch can be used to switch between materials based on user attribute data like per-object id.
Frequently this is used for adding material variation across multiple different objects with one material shading graph. Depending on the requirements of your scene, this can greatly simplify material management.
A material switch can be chained together with additional material switch nodes when 10 variations are not enough.
To switch between textures instead of materials, use the Shader Switch instead.
Parameters
In the example images below there are numbers beneath each sphere, for example 0=0. The first number refers to the sphere's object ID value that is being used to drive the material switch and the second number refers to the shader input slot that is being used. The object ID remains the same but the output shader value can change depending on the shader selector and offset value.
Shader Selector
This value determines which shader from the list of inputs to use. This value typically comes from an integer or scalar stored per-object and is commonly driven by using a
Integer User Data or
Scalar User Data node.
Shader selector can not be driven by bit-map textures. It is limited to per-object or per-vertex data.
|
|
|
|
| Shader Selector: Object ID via User Integer Data | 0 | 2 |
10 (out of range resulting in default shader) |
Offset
The offset shifts the shader input values for a material switch and is most useful when nesting material switches to achieve a shading variation greater than 10.
By default the inputs range from 0-9 with an offset value of 0. However, when an offset value of 10 is used the 0-9 shader inputs then correspond to a range from 10-19. Offset 20 results in 20-29 and so on.
When multiple material switches are connected each offset value only applies to itself and does not affect the other material switches down the line.
Shader 0-9
These are the material input slots, each input corresponds to a value from 0 to 9 when used with the default offset value of 0.
What will ultimately determine what should be connected to each input is dependent on what the material switch output is connected to.
|
| Switching between Materials |
Default Shader
This is the default color or shader that is used when the resulting shader selector value does not match with any of the available shader inputs and it goes out of range (i.e. less than 0 or greater than 9 with default settings).