Mesh Attributes

Mesh Attributes attach static numeric data to a Character's Mesh Assets. The Golaem USD and Arnold procedurals forward this data to the generated meshes, where shaders can read it. Attributes can describe a whole mesh, individual faces, vertices, or face corners. For example, they can store a painted mask, vertex colors, or reference positions named Pref.

Mesh Attributes support in the USD and Arnold procedurals is available in Golaem 9.3.3.

Unlike Shader Attributes, Mesh Attributes are not randomized per Entity or driven by simulation attributes. Their values belong to the Character's mesh and remain unchanged during animation.

Authoring and distributing attributes

Mesh Attributes are stored in a JSON sidecar next to the Character File. For CasualMan.gcha, the sidecar must be named CasualMan_meshAttributes.json. Golaem derives this path from the Character File path; there is no separate file-path setting.

There is no dedicated Mesh Attributes panel in the Character Maker. To author attributes:

  1. Save the Character File and export its geometry as usual.
  2. Create or edit the corresponding _meshAttributes.json file using the format below.
  3. Reload the Character in the Character Maker to load the sidecar. If the Character is already loaded in a rendering application, reload it there too.
  4. Distribute the sidecar together with the Character File and geometry files. If you rename the Character File, rename its sidecar to match.

Saving the Character from the Character Maker also saves its loaded Mesh Attributes to the sidecar. Saving a Character with no Mesh Attributes removes its existing sidecar. To avoid overwriting external edits, reload the Character after editing the JSON and before saving it from the Character Maker.

Authoring with glmCharacterMaker

Scripts can also set Mesh Attributes with the glmCharacterMaker command. Use queryProperties to find the Mesh Asset node, then editProperties in script mode to set its meshAssetAttribute properties. outputFile saves the edited Character and the corresponding JSON sidecar.

For example, this MEL command sets two constant attributes on an existing Mesh Asset named Tshirt:

glmCharacterMaker -script
    -file "C:/characters/CasualMan.gcha"
    -editProperties "MeshAssetNode" "Tshirt"
        "meshAssetAttribute=(attributeName=wearMask;type=float;interpolation=constant;values=0.5);meshAssetAttribute=(attributeName=fabricColor;type=color3;interpolation=constant;values=(0.2,0.4,0.8))"
    -outputFile "C:/characters/CasualMan_withAttributes.gcha";

Each attribute uses the syntax meshAssetAttribute=(attributeName=...;type=...;interpolation=...;values=...). Separate values with commas; enclose each vector or color in parentheses. Attribute names must not contain =, ,, or ;.

Important:

editProperties replaces the target Mesh Asset's entire Mesh Attributes list. Include all attributes you want to retain in the same edit, including __glmMaterialIndex__ when required. If a script saves several meshes to one output Character, use that output Character as the input for subsequent edits so earlier edits are preserved.

JSON format

The root object contains a meshAssetAttributes array. Each entry has the following fields:

Field Description
meshName Exact Mesh Asset name, including any namespace. This is not the Export Alias.
attributeName Name to expose on the generated mesh. Use a unique name for each attribute on a given mesh.
type One of int, float, vector3, vector4, color3, or color4.
interpolation One of constant, uniform, varying, vertex, or facevarying.
values Array of strings containing the values, in the source mesh's topology order. Even scalar numbers must be written as strings.

For example, this file defines a whole-mesh mask and a whole-mesh color:

{
    "meshAssetAttributes": [
        {
            "meshName": "Tshirt",
            "attributeName": "wearMask",
            "type": "float",
            "interpolation": "constant",
            "values": ["0.5"]
        },
        {
            "meshName": "Tshirt",
            "attributeName": "fabricColor",
            "type": "color3",
            "interpolation": "constant",
            "values": ["(0.2, 0.4, 0.8)"]
        }
    ]
}

Data types

Vector and color values use parenthesized, comma-separated components. Use three components for vector3 and color3, and four for vector4 and color4.

Type Example value USD type Arnold type
int "2" int[] INT
float "0.5" float[] FLOAT
vector3 "(1, 2, 3)" float3[] VECTOR
vector4 "(1, 2, 3, 4)" float4[] RGBA
color3 "(0.2, 0.4, 0.8)" color3f[] RGB
color4 "(0.2, 0.4, 0.8, 1)" color4f[] RGBA

Arnold has no four-component vector type, so vector4 uses RGBA. String and Boolean Mesh Attributes are not supported.

Interpolation and value order

Interpolation Values to supply USD interpolation Arnold scope
constant One value for the whole mesh, or an array independent of topology. constant constant
uniform One value per polygon, in polygon order. uniform uniform
varying One value per vertex, in vertex order. varying varying
vertex One value per vertex, in vertex order. vertex varying
facevarying One value per polygon corner, traversing each polygon's vertices in polygon order. faceVarying indexed

USD always exposes the values as arrays. Arnold exposes a single constant value as a scalar and multiple constant values as an array. For facevarying, Arnold also generates the attribute's index array.

Values must match the source geometry's topology. If the geometry is split into render meshes because of multiple material assignments, Golaem remaps the face, vertex, and face-corner values to those render meshes. Regenerate topology-dependent attributes if you change the source mesh's vertex order or topology.

Meshes with multiple materials

FBX geometry provides the material assignments used to remap attributes to each render submesh. For split GCG geometry, vertex remapping uses the original-vertex indices stored in the geometry file.

To remap uniform and facevarying attributes on a split GCG mesh, also supply a Mesh Attribute named __glmMaterialIndex__, with type int and interpolation uniform. Its values must give the zero-based material index for every polygon of the original mesh, in polygon order. For example, a two-face mesh using material 0 on its first face and material 1 on its second face needs values set to ["0", "1"]. The indices must match the material order in the exported geometry.

__glmMaterialIndex__ is reserved remapping data; the USD and Arnold procedurals do not expose it as a shading attribute. Preserve it when editing or distributing attributes for multi-material GCG meshes.

Reading attributes in USD

The USD Procedural exposes Mesh Attributes as properties on the generated USD Mesh, with their type and interpolation. Set glmAttributeNamespace to "primvars" if the attributes need to be exposed as USD primvars. For example, wearMask then becomes primvars:wearMask. The namespace is empty by default. Do not include primvars: in the JSON attribute name when using this setting.

Mesh Attributes are static; they do not acquire time samples from the simulation. Avoid names that collide with built-in mesh properties or other attributes on the same mesh.

Reading attributes in Arnold

The Arnold procedural declares Mesh Attributes as user data on the generated meshes. Use a user-data shader matching the attribute's type and set its attribute name to the JSON attributeName, without a USD namespace prefix. For example, use aiUserDataFloat to read wearMask, or aiUserDataVector for a vector3 attribute.

Reference positions (Pref)

To provide reference positions for an Arnold shading network, author a vector3 attribute named Pref with vertex interpolation. Supply one position per source mesh vertex, taken from the reference geometry in the coordinate space expected by the shader.

For a mesh consisting of a single triangle with three vertices, an entry could be:

{
    "meshAssetAttributes": [
        {
            "meshName": "Triangle",
            "attributeName": "Pref",
            "type": "vector3",
            "interpolation": "vertex",
            "values": ["(0, 0, 0)", "(1, 0, 0)", "(0, 1, 0)"]
        }
    ]
}

Read Pref with aiUserDataVector and connect it to the shading network's reference-position input. Golaem forwards the supplied positions unchanged; it does not automatically generate Pref from the bind pose or deform these values with the animated mesh.

In Maya, a Pref color set can be used to preview the same reference positions: store each vertex's XYZ coordinates in its RGB components, using an unclamped RGB color set. Capture the coordinates at the desired reference pose, in object space unless the shader expects another space. On a deformed mesh, write the preview colors to the original pre-deformation shape so deformers do not overwrite them.

The Maya color set is a preview, not an automatic export source for Golaem. The coordinates must also be written to the Character's Mesh Attributes using the JSON format or scripted command described above.

Verifying the workflow

Use the same source geometry and vertex order as the Character's exported geometry. Include a mesh with multiple material assignments to check that attributes stay aligned after splitting into render submeshes.

  1. Capture the reference vertex positions with vertex interpolation. For the Arnold test, write them as a vector3 attribute named Pref. For a USD viewport test, write the same XYZ components as a color3 attribute named displayColor; this maps to USD color3f[], allowing USDView or Houdini to display the primvar as colors.
  2. When testing split GCG geometry, also write __glmMaterialIndex__ using the Mesh Asset's shading-group order, not an arbitrary ordering of Maya materials.
  3. Save the edited Character to a new file, for example CasualMan_Pref.gcha or CasualMan_displayColor.gcha. Check that its matching _meshAttributes.json file exists in the same directory.
  4. Set the Entity Type's Character File to the new Character, relocate any geometry or motion files as needed, and check that the simulation works. Export the simulation cache with valid output paths.

USD viewport check

  1. Bake the exported cache with USD Mode set to USD Procedural.
  2. To visualize displayColor as a primvar, set glmAttributeNamespace to "primvars".
  3. Open the generated .usda file in USDView or Houdini with the matching Golaem for USD plug-in installed. Inspect the generated Mesh's primvars:displayColor values and interpolation.
  4. Compare the character's displayed color pattern with the reference vertex colors in Maya. Check every material submesh for missing colors or discontinuities caused by incorrect remapping.
  5. Change frames. The geometry should animate while the reference attribute values remain unchanged and the pattern stays attached to the surface.

USDView displaying reference-position colors and the selected Mesh's primvars:displayColor values

Reference positions visualized as displayColor in USDView, with the generated Mesh's primvars:displayColor array selected.

If USDView does not offer the desired playback range, add startTimeCode and endTimeCode to the generated layer's metadata. Keep its existing defaultPrim value and use your exported cache range. For example, for frames 1 through 500:

#usda 1.0
(
    defaultPrim = "renderProxyShape1"
    startTimeCode = 1
    endTimeCode = 500
)

Arnold render check

  1. Use the Character containing the Pref attribute and its sidecar.
  2. Read Pref with aiUserDataVector and route the result to a diagnostic AOV named Pref.
  3. Render with Arnold and display the Pref pass. Compare its spatial pattern with the reference-position colors in Maya or the USD displayColor test.
  4. Render another animation frame and check that the pattern stays attached to the deformed surface, including across material submeshes.

Arnold Pref diagnostic pass displaying reference positions as colors on crowd characters

Arnold Pref diagnostic pass showing reference-position colors on the rendered crowd characters.

The viewport and render checks visualize XYZ coordinates as colors; they are diagnostic patterns, not the Character's final material colors. Negative coordinates or values above one can lie outside the display range, so inspect the attribute values as well as the displayed image.

Troubleshooting