UsdPrimvarSet

Primvars (short for primitive variables) are particular kinds of attributes that have two main functions:

  • Store data that varies through interpolation - Primvars are used to hold data that varies over the surface of a primitive like UV coordinates or vertex colors.

  • Override attributes on a per-primitive basis - Primvars can override attributes on a particular primitive, meaning you can customize the appearance or behavior of individual primitives within the scene hierarchy independently of others. This lets you change the details on a primitive that may be subject to shared attributes. For example, changing the color of one tree in a forest from green trees to red.

For example, consider a simple line defined by two points (vertices). You could define a color primvar to indicate that the color must change along the line from red to blue and that it is uniformly interpolated:

Copy
def BasisCurves "SimpleLine" {
    int[] curveVertexCounts = [2]  #Number of vertices
    point3f[] points = [(0, 0, 0), (1, 1, 1)] #Co-ordinates of the endpoints


    # The primvar for color:
    color3f[] primvars:color = [(1, 0, 0), (0, 0, 1)]  # Red to Blue
   uniform token primvars:color:interpolation = "vertex" #Interpolate the color  
                                                                                             #between the vertices
}

For more information see Primvar in Pixar’s USD Glossary.

You can set a new primvar, or override the value of an existing one. Alternatively, you may need to remove a primvar’s effect on the stage. These are achieved by selecting Create/Override or Block in the action dropdown.

Like Attributes, the value Primvars can be time-sampled, in that they can vary according to time. For this kind of primvar, set multisample to Yes.

Primvars offer a number of interpolation types to transition data between each data point and one is selected using interpolation. For more details on each, see the table below.

Inputs

Connection Type

Connection Name

Function

input in The incoming scene graph data that the node will operate on or modify.

Controls

Control (UI)

Default Value

Function

action

Create/Override

Choose how you want to apply the primvar update. 

Create/Override - Create the primvar, or if it exists already, assign the new value.

Block - Disable the primvar assignment in the prim(s), removing their effect from stage composition.

name

n/a

Assign a name to the primvar.

type

Double

Choose a data type for the primvar.

multisample

Yes

Select Yes if the data is time-sampled.

isCustom

No

Select Yes if this is a custom primvar.

interpolation

constant

Choose the interpolation type:

  • Constant - Uses only one constant value for the prim. For example, a single color applied to an entire mesh.

  • Uniform - Uses one value per geometric element, such as a face in a mesh. For example, if you have a cube and want each face to have a different color, you would use uniform interpolation..

  • Varying - Uses one value for each vertex, but the value is smoothly interpolated over the whole face. This can an be used for smooth color gradients across faces.

  • Vertex - Uses one value per vertex of the primitive. For a mesh, this could be colors or UVs specified at each vertex, leading to gradients across the faces.

  • FaceVarying - Uses one value per vertex per face. This is often used for UV coordinates and allows for each face of a mesh to have its own separate set of UVs or vertex attributes, even if the vertices are shared between faces.

Note:  The names of these types are different to the convention used by Katana’s arbitrary attributes’ scope. For reference, see Arbitrary Attributes.

value

n/a

Assign a value to the primvar.