Square Enix © Goodbye Kansas

Table of Contents

This page provides information on the V-Ray User-defined Color Map.


Overview


The VRayUserColor texture can be used to read User-Defined object properties from the currently shaded node and convert them to a color value. This allows you to use the same shading network on several different objects in the scene, but to control various aspects of the material through User-Defined properties. This texture also has the ability to read mesh color sets, UV sets, and extra channel information from VRayProxy File Formats objects, as well as additional data channels from other plugins like Yeti.

The Example on the right uses a VRayUserColor node to control the diffuse value on a single V-Ray Material. The four different pieces of the shader ball have a VRayUserAttribute that dictates different values.




Parameters


User attribute name – Specifies the name of the user attribute that is looked up and returned from this shading node.

Default color – Specifies the color to return if the user attribute is not found on the shaded object.

Required format for attribute name – Displays possible formats for the attribute in the V-Ray User Attributes string assigned to the object and what is rendered as a result.



Examples


Example: User Properties


In the example below, user attributes are assigned to different objects with different values. A VRayUserColor texture reads the values and passes them to a shader at render time. This way we can pass different shader values that are controlled at the object level, allowing us to share the shader between all objects.

With the help of a user attribute we can control any color parameter of the shader.


User attributes can be added though the Attributes > VRay > User attributes menu.


The same material is applied to both objects. A VRayUserColor texture passes the values to the shader.



User attribute for the first object


User attribute for the second object



Although the two objects have the same material, the diffuse color is determined by the user property.



Example: Animated Custom Color Attribute


A VRayUserColor texture can control VRayMtl color parameters by a user attribute in an animation. A user attribute is assigned to an object with the help of scripting.

For this example, use MEL scripting to create a custom attribute of type float3, called myColor with a vrayUserColor_ prefix. The type float 3 means that this attribute holds 3 float values.

addAttr -ln "vrayUserColor_myColor" -at float3 -keyable true -uac pSphere1;

Add three float attributes: one for each R, G and B color component. Make them children of the float3 attribute.

addAttr -ln "vrayUserColor_myColorR" -at "float" -keyable true -p vrayUserColor_myColor pSphere1;
addAttr -ln "vrayUserColor_myColorG" -at "float" -keyable true -p vrayUserColor_myColor pSphere1;
addAttr -ln "vrayUserColor_myColorB" -at "float" -keyable true -p vrayUserColor_myColor pSphere1;

This setup can be used on multiple objects sharing the same shader by simply modifying and re-using the script for other objects.




The user attributes are accessible from object's Extra Attribute rollout or the Channel Box.

Make key frames and set different values of the user attribute for each key frame of the animation.

Scripted custom color attributes cannot be textured.




Assign a VRayMtl to the object. Link a VRayUserColor's оutColor to the VRayMtl Diffuse Color input.

Assign myColor as the User attribute name in VRayUserColor. Note that the vrayUserColor_ prefix is not needed here.




Frame 1


Frame 2


Frame 3



Example: Rendering Vertex Colors


The VRayUserColor texture can be used to render objects colored with vertex color painting.

Here is how it’s done:

  1. Create a VRayMtl and assign it to the object that has painted vertex colors.
  2. Create a VRayUserColor texture and link it to the Diffuse map slot of the VRayMtl.


3. Get the name of the color set. The easiest way to do this is by opening the Color Set Editor from Mesh Display > Color Set Editor and selecting the object in the viewport. This displays the available color sets in the Color Set Editor dialog.


4. In the Color Set Editor, Ctr+C copy the color set name.


5. Paste the name in the User attribute name field and render.


Notes


  • When rendering with IPR GPU, VRayUserColor supports setting UV and color sets from proxies and regular geometry.