Versions Compared

Key

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

...

Step 1: Set the object property attribute

...

Section
Column
width50%55%

To set an object property or attribute, do the following:

1. Create a VRayProxy object and load your vrmesh in it.

2. Right click on it and go to Object Properties > User Defined. In the User Defined Properties field, enter an attribute name and a value for it. In this case it is:

dough = 0

Attributes can have any kind of value. Here we use numeric value in order to specify a number for selecting VRaySwitchMtl sub-material later on.

Column
width5%
 
Column
width45%40%

Image Modified

 

Step 2: VRaySwitchMtl and VRayUserScalar

...

Section
Column
width50%55%

In this scene, we want to use seven different cookie materials.

Create a VRaySwitchMtl in the Material Editor. Place all cookie materials in the Materials slots (here numbered from 0 to 6).

Let's see how to match each sub-material with the geometry's attribute value we specified.

Set VRayUserScalar as a Switch map. It can read custom user attribute value and feed it to the switch.

Column
width5%
 
Column
width45%40%

 

...

 

Section
Column
width50%55%

Go to the VRayUserScalar parameters.

For Attribute name, enter the user defined property name you used for all of the objects in the scene. In this scene, we use dough.

Assign the VRaySwitchMtl to the VRayProxy object. It renders with the sub-material from slot 0.

You can edit the user defined attribute value and the change respectively affects the material choice.

Each of the materials is now available to all VRayProxy instances and picked accordingly to match the specific attribute value.

Column
width5%

 

Column
width45%40%

 


Step 3: Using Proxy Instances

...

Section
Column
width50%55%

Let's see how to work with proxy instances and user defined properties.

We've named the proxies Cookie_0.vrmesh, Cookie_1.vrmesh, Cookie_2.vrmesh, etc., which now comes handy, as we want to use a tag to specify the Mesh file name in each instance we make.

Go to the Mesh file field of each proxy instance, and in the place of the number suffix, put a tag using the <> brackets.

The tag should be the object property name (the same one we used for the Switch).

Here the Mesh file is Cookie_<dough>.vrmesh.

Now this tag serves us instead of the numerical suffix, allowing us to load whichever proxy in the place of the instance.

UI Text Box
typetip

The mesh preview is not available with this setup, but you can render and make sure that the mesh corresponding to the custom attribute value is loaded.

Column
width5%
 
Column
width45%40%

Image Modified

 

...

 

Section
Column
width50%55%

Make a bunch of instances of the VRayProxy object and change their dough value using numbers from 0 to 6.

This way, the value of the attribute determines which proxy is loaded during rendering.

Also, the proxies have the VRaySwitchMtl assigned by default, so that each proxy gets its respective material based on the same attribute value.

Column
width5%

 

Column
width45%40%

Image Modified

 

...

 

Section
Column
width50%55%

Here is a rendered example with seven instances of one proxy, loading various proxy geometry and its respective material.

Column
width5%

 

Column
width45%40%

Image Modified

 

...

 

Section
Column
width50%55%

We can make multiple instances of these VRayProxy objects and tweak just the user defined attribute value where needed to pick a different mesh and automatically render it with its proper material.

Column
width5%

 

Column
width45%40%

Image Modified