This page provides a guide to the V-Ray user attributes with two example use cases, which you can try for yourself.
Overview
User attributes can source data from the various areas of the scene and apply these values to the V-Ray shaders using the User Integer, User Scalar, and User Color nodes and textures. User Attributes allow for per-shader modifications. There are a number of predefined attributes that can be selected from the User Attribute dropdown menu of the aforementioned textures. Users can also create custom attributes through User Data and Vertex Tags.
For an example, see the provided tutorials. You can download the attached scenes and follow along:
How to Create Custom User Attributes
The manual method to add user attributes is through the User Data fields in an object's attributes. This method works on the object level. To add User Data, go to the User Data menu in the Attribute tab and select Add User Data.... This opens the Manage User Data window, where you can determine the name and type of data you would like to store and its properties.
See the supported data types in the Maxon documentation.
The second method involves adding Vertex Color or Vertex Map tags to an object. This method applies the attributes on the vertex level and is only applicable to mesh objects in the scene.
You can find the Vertex Color and Map tags in the Objects panel. Open the Tags tab > Other Tags.
Predefined User Attributes
Predefined Mogprah Attributes are applicable to the MoGraph Cloner object, some Scatter objects, and other instancing methods, as well as objects that used to be MoGraph objects, like the Text Spline.
Predefined V-Ray Attributes are applicable to all geometries in the scene, even MoGraph objects.
These attributes can be read with the V-Ray User Color, V-Ray User Integer, and V-Ray User Scalar node textures and classic textures.
MoGraph Attributes
UI Name | Full Name | Definition |
---|---|---|
Color | VRAY_MOGRAPH_COLOR | The color value of the Cloner object. |
Color sRGB | VRAY_MOGRAPH_COLOR_SRGB | The color of the Cloner object in sRGB color values. |
ID Ratio (Color) | VRAY_MOGRAPH_RATIO_COLOR | The index ratio of the Cloner as a grayscale color value. |
ID Ratio | VRAY_MOGRAPH_RATIO | The index ratio of the Cloner as a zero to one float value. |
Index (Normalized) | VRAY_MOGRAPH_INDEX_NORMALIZED | The index ratio of the clone as a zero to one float value. |
Index | VRAY_MOGRAPH_INDEX | The index ratio of the clone. |
Weight | VRAY_MOGRAPH_WEIGHT | The MoGraph Weight attribute as a zero to one float value. |
Clone Offset | VRAY_MOGRAPH_CLONE_OFFSET | The MoGraph Clone Offset attribute as a zero to one float value. |
Time Offset | VRAY_MOGRAPH_TIME_OFFSET | The MoGraph Time Offset attribute as a zero to one float value. |
Falloff Weight | VRAY_MOGRAPH_FALLOFF_WEIGHT | The MoGraph Falloff Weight attribute as a zero to one float value. |
Size | VRAY_MOGRAPH_SIZE | The Cloner's size attribute as a vector value. |
UVW | VRAY_MOGRAPH_UVW | The Cloner's UVW attribute as a vector value. |
V-Ray Attributes
UI Name | Full Name | Definition |
---|---|---|
Object Color | VRAY_OBJECT_COLOR | The default color of the object. This color can be changed from the project settings. |
Display Color | VRAY_DISPLAY_COLOR | The object or layer color depending the Display Color option in the geometry's Basic Attributes tab. |
Layer Color | VRAY_LAYER_COLOR | The color of the layer that the object is placed in. |
Object ID | VRay_ObjectID | Overrides the Object ID, if specified in the applied V-Ray Object Properties. |
SSS Surface ID | VRay_SSS_SurfaceID | Takes the Sss Surface ID value from the applied V-Ray Object Properties. |
Instance ID | VRAY_EXPLICIT_INSTANCE_ID | Takes the ID of the instances. Works with the MoGraph Cloner and other instancing tools. |
Applying a Vertex Map to a V-Ray Material
This example shows how to link a vertex map to a V-Ray Material and use it to create a procedural texture. Here are the main steps, you can watch the video for a full tutorial:
- Assign a Vertex Map tag with a field to the geometry you wish to edit.
- Assign a Node Material to that geometry.
- Create a Vertex Color node and apply the Vertex Map to its Vertex Map slot.
- Connect the Vertex Color node to an input slot in the material, or adjacent textures that accepts numeric values.
This scene is originally made with V-Ray 7, hotfix 1.
Download the scene and follow along.
Controlling Materials with User Data
This example shows how you can control V-Ray materials with MoGraph User Data. Here are the main steps; watch the video for a full tutorial.
Switch between materials using User Integer:
Sample the indexes of each clone and use them to determine the Switch value of a V-Ray Switch Node or Classic Material. To do so, create a User Integer Node or Classic texture and set its User Attribute property to MoGraph > Index. This will sample the integer values of the indexes given to each MoGraph instance.
Link the User Integer to the Switch input of the V-Ray Switch Material.
(If the Switch input is hidden when working in the Node Editor) To reveal the Switch input port, right-click on the Switch material node and select Add Input > Materials > Switch.
Sample different areas of a Ramp node using User Scalar (this workflow is specific to Node Materials):
Create a User Scalar node and set its User Attribute to MoGraph > Index (Normalized). It is important you set it to Normalized, as we want the data to be in the form of values from 0 to 1.
Create a Color to UVW node to convert the data to Context data.
Link the User Scalar to the V input of the Color to UVW, as our ramp is set to Type V. You might need to connect it differently if you are using a different type of Ramp.
Connect the Color to UVW to the Context input of the Ramp node.
This scene is originally made with V-Ray 7, hotfix 1.
Download the scene and follow along.