Table of Contents

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 NameFull NameDefinition
ColorVRAY_MOGRAPH_COLORThe color value of the Cloner object.
Color sRGBVRAY_MOGRAPH_COLOR_SRGBThe color of the Cloner object in sRGB color values.
ID Ratio (Color)VRAY_MOGRAPH_RATIO_COLORThe index ratio of the Cloner as a grayscale color value.
ID RatioVRAY_MOGRAPH_RATIOThe index ratio of the Cloner as a zero to one float value.
Index (Normalized)VRAY_MOGRAPH_INDEX_NORMALIZEDThe index ratio of the clone as a zero to one float value.
IndexVRAY_MOGRAPH_INDEXThe index ratio of the clone.
WeightVRAY_MOGRAPH_WEIGHTThe MoGraph Weight attribute as a zero to one float value.
Clone OffsetVRAY_MOGRAPH_CLONE_OFFSETThe MoGraph Clone Offset attribute as a zero to one float value.
Time OffsetVRAY_MOGRAPH_TIME_OFFSETThe MoGraph Time Offset attribute as a zero to one float value.
Falloff WeightVRAY_MOGRAPH_FALLOFF_WEIGHTThe MoGraph Falloff Weight attribute as a zero to one float value.
SizeVRAY_MOGRAPH_SIZEThe Cloner's size attribute as a vector value.
UVWVRAY_MOGRAPH_UVWThe Cloner's UVW attribute as a vector value.


V-Ray Attributes

UI NameFull NameDefinition
Object ColorVRAY_OBJECT_COLORThe default color of the object. This color can be changed from the project settings.
Display ColorVRAY_DISPLAY_COLORThe object or layer color depending the Display Color option in the geometry's Basic Attributes tab.
Layer ColorVRAY_LAYER_COLORThe color of the layer that the object is placed in.
Object IDVRay_ObjectIDOverrides the Object ID, if specified in the applied V-Ray Object Properties.
SSS Surface IDVRay_SSS_SurfaceIDTakes the Sss Surface ID value from the applied V-Ray Object Properties.
Instance IDVRAY_EXPLICIT_INSTANCE_IDTakes 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:

  1. Assign a Vertex Map tag with a field to the geometry you wish to edit.
  2. Assign a Node Material to that geometry.
  3. Create a Vertex Color node and apply the Vertex Map to its Vertex Map slot.
  4. 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.

Download the scene







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:

  1. 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.

  2. Link the User Integer to the Switch input of the V-Ray Switch Material.

    1. (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):

  1. 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.

  2. Create a Color to UVW node to convert the data to Context data.

  3. 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. 

  4. 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.

Download the scene







Was this helpful?