Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page provides a guide to the V-Ray user attributes with two example use cases, which you can try for yourself.


Overview

...

Section
Column
width50%

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:

Section
Column
width30%
Panel
borderColor#0DB5FF
borderStylesolid

Vertex Maps


Column
width10%


Column
width30%
Panel
borderColor#0DB5FF
borderStylesolid

User Attributes

Column
width30%




Column
width5%


Column
width45%

...


How to Create Custom User Attributes

...

Section
Column
width50%

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.

Column
width5%


Column
width45%

Image Added


...


Section
Column
width60%

The second method involves adding Vertex Color

...

MoGraph Attributes in this list are applicable only to the MoGraph Cloner object when V-Ray User Color is applied to it. These attributes list the source, from which they gather data to feed into the User Color texture or node.

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.

Column
width5%


Column
width35%

Image Added


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.


...

Section
Column
width47%

MoGraph Attributes

UI NameFull NameDefinition
ColorVRAY_MOGRAPH_COLOR
The 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_RATIO
The 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 Offset

...

VRAY_MOGRAPH_CLONE_OFFSETThe MoGraph Clone Offset attribute as a zero to one float value.

...

Time Offset

...

VRAY_MOGRAPH_TIME_OFFSETThe MoGraph Time Offset attribute as a zero to one float value.
Falloff Weight

...

VRAY_MOGRAPH_FALLOFF_WEIGHTThe MoGraph Falloff Weight attribute as a zero to one float

...

value.
Size

...

VRAY_MOGRAPH_SIZEThe Cloner's size attribute as a vector value.
UVW

...

VRAY_MOGRAPH_UVWThe Cloner's UVW attribute as a vector value.

...

Column
width5%


Column
width48%

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.


Anchor
vertex
vertex

Applying a Vertex Map to a V-Ray Material

...


Section


Column
width50%

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.

UI Button
colorgreen
icondownload
titleDownload the scene
urlhttps://drive.google.com/file/d/1IKaP06WhY32jncWKyxRI-52VjR4Z-n0B/view?usp=drive_link


Column
width5%



Column
width45%
HTML
<iframe width="560" height="315" src="https://www.youtube.com/embed/yR6m9abRIN0?si=08db_jgEiPqPP_NU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>




Anchor
data
data

Controlling Materials with User Data

User Scalar

...

...


Section


MoGraph Attributes

ID Ratio – The ID ratio of the clone as a zero to one float value.

Index (Normalized) – The index ratio of the clone as a zero to one float value.

Index – The index ratio of the clone.

Weight – The MoGraph Weight attribute as a zero to one float value.

Clone Offset – The MoGraph Clone Offset attribute as a zero to one float value.

Time Offset – The MoGraph Time Offset attribute as a zero to one float value.

Falloff Weight – The MoGraph Falloff Weight attribute as a zero to one float value

Alternative ID – The clone's Alternative ID as an integer value.

Column
width45%
50%

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.

UI Button
colorgreen
icondownload
titleDownload the scene
urlhttps://drive.google.com/file/d/1xgmPYaLAS8FJzP2lXhLh2p8I1Qzumlu6/view?usp=drive_link


Column
width5%
Column
width10%



Column
width45%
HTML
<iframe width="560" height="315" src="https://www.youtube.com/embed/QfhYJfm1cLc?si=FSXbGgp6_ym0HE8A" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

Cinema 4D Attributes

Object ID – Overrides the Node Object ID, if specified.