On this page | |
Since | 18.0 |
How to ¶
To... | Do this |
---|---|
Assign a material to one or more primitives |
|
Assign computed materials using VEX (advanced) |
|
Override material parameters using VEX (advanced) |
This lets you compute different values for material parameters for each assignment.
|
Assign materials to individual elements in geometry using VEX (advanced) |
The node will automatically create geometry subsets for each set of elements with the same material path. |
Using CVEX VOP networks (not recommended) ¶
Note
We strongly encourage you to use VEXpressions instead of CVEX VOP networks. As detailed below, CVEX networks require multiple steps to set up. Unless you need a very elaborate VOP network to do the computation, or want to re-use some existing VOPs, writing a VEX snippet is much easier.
-
Set either Specify material using or Parameters override to “CVEX”.
-
The most convenient place to create the CVEX VOP network is inside the Assign Material node itself (it contains a VEX Builder network). Dive inside, press ⇥ Tab and create a CVEX Shader Builder network node.
-
Rename the CVEX Builder with a memorable name based on what the network will do (for example,
material_assignment
). If you are doing multiple assignments in the Assign Material node, using multiple CVEX networks, they must each have unique names. -
Dive inside the CVEX Builder node and put down a USD Global Parameters node. This provides the basic inputs (
primpath
,elemnum
, andnumelem
). -
If the Assign Material node is creating bindings, you can add corresponding Parameter VOPs in this network to represent the bound VEX variables.
If you are assigning to parameters to override material attributes, remember to set the Parameter VOP’s Export parameter to “Always” or “When input is connected”.
-
If you are using the network to compute material assignments, create a single Parameter VOP at the end of the network to represent the “return” value. Set its Name to
matname
, set its Export parameter to “Always”, and connect the rest of the network to its input. -
Fill in the VOP network to do the computation you want.
-
Go back up to the Assign Material node’s parameters. In the CVEX node or Override CVEX node parameter, enter the path to the CVEX network you just created.
If you created the network inside this Assign Material node, you can simply enter the network’s name, for example
material_assignment
.If you created the network elsewhere, you must enter a path to the network node, for example
/mat/material_assignment
.
Tips ¶
-
In VEX snippets, you can use
@
variable names containing colons (:
). This makes it easier to automatically bind certain USD attribute names (for examplei@primvars:foo
). (These names are not normally legal in names in VEX source code. The node automatically encodes these kinds of names when used in a snippet.)
Parameters ¶
Number of materials
You can perform multiple assignments within one node. Set this to the number of assignments you want to perform, or use the plus and minus button to add or remove assignments.
Primitives
The primitive(s) you want to assign the material to. You can click the select button beside the text box to select the primitives from the scene graph tree. You can also use primitive patterns for advanced matching.
Specify Material Using
How to specify the material to assign.
Explicit path
Assign a material at a certain path in the scene graph tree.
VEXpression
Assign a material to each selected primitive based on the results of computing a VEX snippet.
CVEX Script
TBD.
Material Path
When Specify material using is “Explicit path”, the USD path to the material primitive to use for binding.
VEXpression
When Specify material using is “VEXpression”, this VEX snippet is computed for each selected primitive. You can use @primpath
(the path of the current primitive), @elemnum
(the index of the current prim in the list of selected prims), and @numelem
(the total number of selected prims). Must return a string containing a path to the material to assign to the current prim.
For example, this snippet alternates between assigning rough_red
and rough_blue
based on whether a primitive is at an odd or even position in the list of selected primitives:
return (@elemnum % 2) ? "/materials/rough_red" : "/materials/rough_blue";
CVEX Node
When Specify material using is “CVEX”, the path to a CVEX VOP network. See CVEX VOP networks above.
Parameters Override
Whether and how to override individual material parameters for each assignment.
None
Do not override material parameters.
VEXpression
Run a VEX snippet for each assignment that can compute new parameter values.
CVEX Script
Run a VEX program, provided by a CVEX node, to compute override values for material parameters.
Override VEXpression
When Parameter override is “VEXpression”, this VEX snippet is run for each selected primitive. The settings under “CVEX Bindings” control how material parameters are mapped to VEX variables. You override a material parameter by assigning to the corresponding variable. You can also use @primpath
(the path of the current primitive), @elemnum
(the index of the current prim in the list of selected prims), and @numelem
(the total number of selected prims).
For example, if the material has a parameter named roughness
(and Autobind by name is on, the default), you can override it by setting the corresponding variable in the VEX snippet:
@roughness = (@elemnum % 3) ? 0.25 : 0.5;
Override CVEX Node
When Parameters override is “CVEX”, the path to a CVEX VOP network. See CVEX VOP networks above.
VEX Bindings to Export
A pattern that selects VEXpression parameters that should be exported from the final VEX program. I.e., these are the output parameters that will be used for material parameter override.
Materials Parent Path
Specifies the USD path to the parent primitive inside which the LOP should author any automatically created materials with overrides.
Materials Parent Type
Specifies the primitive type of any ancestors that needs to be authored in order to automatically create materials with overrides.
Autobind by Name
When this is on, attributes on the current primitive (when computing assignment) or on the material (when computing overrides) are automatically made available as VEX variables with the same name in the relevant VEXpression (or CVEX network). You can turn this off and map attribute names to VEX variable names manually using the multiparm below.
Number of Bindings
The number of manual attribute to VEX variable bindings to create.
Attribute Name
In a binding pair, the name of the USD attribute to convert to a VEX variable.
VEX Parameter
In a binding pair, the name of the VEX variable to create to mirror the USD attribute.
Create and Bind Geometry Subsets
When this is on, the Primitives parameter should point to a geometry or geometry subset primitive, and the node runs the VEX snippet for each geometry element (for example, polygon face) in the geometry, instead of for each selected primitive. In the snippet, @elemnum
is the index of the current element, and @numelem
is the total number of elements in the geometry.
The node will automatically create geometry subsets for each set of elements with the same material path.
Purpose
Sets the purpose
value for the assignments. This controls what types of renders the assignment applies to.
All
The assignments apply to all rendering.
Full Render
The assignments only apply in full/final renders.
Preview Render
The assignments only apply in preview renders.
Strength
Controls the strength of the assignment “opinion” relative to any conflicting assignments on descendant prims under the assigned primitives in the tree. (For example, if this node assigns /materials/zerbra
to /a
, but /a/b/c
already is assigned /materials/tiger
).
Default
Use normal rules for opinion strengths (assignments on descendants override assignments on ancestors).
Stronger than descendants
This assignment always overrides assignments on primitives lower in the tree.
This is useful if you want collection-based binding to override child primitives that already have a material binding. This option ensures the collection-based binding on the ancestor takes effect despite the general rule that descendant opinions are stronger than ancestors.
Weaker than descendants
This assignment is always overridden by assignments on primitives lower in the tree. This is the same as “Default”.
Method
How to express the material assignment in USD.
Direct
Assign the material by authoring a material:binding
relationship on each individual primitive.
Collection based
Assign each material to a collection of primitives on a common ancestor using the material:binding:collection
relationship. If you specified the primitives using a collection in the Primitives parameter, this will re-use that collection. Otherwise, you can specify the path to the a prim using the Path parameter below and the node will create a new collection on that prim.
Note
The USD specification for the collection-based material binding says that the material is assigned only to primitives that are descendants of the primitive on which the binding relationship is defined (see Path parameter). That is, the binding does not affect any primitives in the collection that are not descendants of that primitive.
Include Descendant Primitives in Collection
When Method is “Collection based”, turn on this option to have the collection authored for the collection-based binding be marked to expand all descendants of the target primitives. This will cause the material assignment to be applied to the entire scene graph tree branch. The equivalent of this behavior always occurs when using “Direct” binding, which always inherits down the scene graph tree.
Path
When Method is “Collection based”, the collection-based binding will be defined on a primitive at this path.
Also, if this LOP node needs to create a new collection, it will create it on a this primitive as well.
If the path is empty, the LOP node tries to use the deepest ancestor common to all primitives given in the Primitives parameter.
Name
Specifies the collection-based material binding name. If empty, the name of the material will be used.
See also |