Ai UserData Color

Different colored models are driven by one Ai UserData Color node


This short tutorial covers how to use the 'Ai UserData Color' node to assign a single shader with different colors to the three models in the scene. 

The scene can be downloaded here.

 

  • In this scene, there are three robot models. We want to assign red, blue and green colors to each model. Start off by selecting all three robots and assign an Ai Standard Surface shader to them.

Robots with one shader assigned to them all

 

  • Create an Ai UserData Color node and connect it to the Base Color attribute of the Ai Standard Surface shader.

 

  • Select the Ai UserData Color node and in the text field next to Color Attr Name type 'color'.

 

  • Select one of the robots. Add an attribute to it. Make sure to select the robot's shape node so that the attribute is added correctly. To do this, press the Focus button in the attribute editor with the robot geometry selected.

Select the Focus button to select the robot model's shape node

 

Add Attribute

  • Add an attribute to the robot's shape geometry node (Attributes > Add Attribute). Type 'mtoa_constant_color' in the field next to 'Long name'. Note that you must use lower case letters. Capital letters will not work. Change the Data Type to VectorThis will enable us to change the RGB values of the color output of the Ai Standard Surface shader.

Add the name 'mtoa_constant_color' and change the Data Type to Vector

 

  • With the robot shape node selected, open up Extra Attributes at the bottom of the attribute editor. You should see the new Mtoa Constant Color attribute with three vector fields for each RGB channel.

 

  • Change the first Mtoa Constant Color to 1 and render the scene. You should see that the robots color has changed to red because we have added 1 to the R field of the Mtoa Constant Color.

 

  • To change the colors of the other robots, repeat the process above. However, in the Ai UserData Color node, change the first R field to 1 for one robot, the G field to 1 for the second and the B field to 1 for the third robot. You should see something like the image below:

RGB robots with metallic eyes

 

Default Value

  • We can also use the same shader for the eyeball. If we change the Default Value of the Ai UserData Color node to white, the eyeballs will be white because we have not added a Mtoa Constant Color attribute to its shape node. It will change the color to white to any objects that have been assigned the Ai Standard Surface shader that has the Ai UserData Color node connected to it (you can also drag and drop a shader onto this attribute too).

Change the 'Default Value' color to white or middle drag a white shader onto this attribute

 

 

'Default Value' has been changed to white for the eyeballs

 

 

 

  • No labels