Skip to content

[Apple] Support MaterialX UsdPrimvarReader in Storm#4091

Closed
ld-kerley wants to merge 1 commit into
PixarAnimationStudios:devfrom
ld-kerley:matX-UsdPrimvarReader-support
Closed

[Apple] Support MaterialX UsdPrimvarReader in Storm#4091
ld-kerley wants to merge 1 commit into
PixarAnimationStudios:devfrom
ld-kerley:matX-UsdPrimvarReader-support

Conversation

@ld-kerley

@ld-kerley ld-kerley commented May 30, 2026

Copy link
Copy Markdown
Contributor

Description of Change(s)

This is built on top of a corresponding MaterialX PR, that fixes nested geomprop nodes:
AcademySoftwareFoundation/MaterialX#2957

Rendering a MaterialX UsdPreviewSurface network that reads a primvar through an ND_UsdPrimvarReader_* node (for example varname="st" feeding a UsdUVTexture) failed in Hydra Storm with:

  HdSt_ApplyMaterialXFilter -- Unable to create the Glslfx Shader.
  MxException: No "geomprop" value found for geompropvalue node "primvar".

That crash exposed a few different issues this PR fixes, all in how hdMtlx/hdSt build the document and emit the glslfx.

  1. Preserve the topology-affecting primvar name. The topological classification (_IsTopologicalShader) only recognized the native geompropvalue family, so the UsdPrimvarReader varname was stripped from the anonymized network.

  2. Recognize primvar-reader nodes generically (hdMtlx). A node is treated as a primvar reader when its implementation nodegraph wraps a geompropvalue or geompropvalueuniform node. New helpers discover this and the input names that carry the primvar name and fallback. Detecting by implementation structure rather than by family name keeps this robust for any future node that wraps a geompropvalue.

  3. Emit glslfx-compatible primvar types (hdSt/materialXShaderGen.cpp). The primvar attributes block of the generated glslfx took its type name from the target shader language syntax. On Metal that produced names like float2, which HioGlslfxConfig does not understand (it accepts vec2), so the primvar declaration was rejected. The attributes type is now mapped to a glslfx type independent of the target language.

Unit test files are attached here - test_file.zip

Checklist

This is built on top of a corresponding MaterialX PR, that fixes nested
geomprop nodes:
AcademySoftwareFoundation/MaterialX#2957

Rendering a UsdPreviewSurface network that reads a primvar through an
ND_UsdPrimvarReader_* node (for example varname="st" feeding a UsdUVTexture)
failed in Hydra Storm with:

  HdSt_ApplyMaterialXFilter -- Unable to create the Glslfx Shader.
  MxException: No "geomprop" value found for geompropvalue node "primvar".

That crash exposed a few different issues this PR fixes, all in how
hdMtlx/hdSt build the document and emit the glslfx.

1. Preserve the topology-affecting primvar name. The topological
   classification (_IsTopologicalShader) only recognized the native
   geompropvalue family, so a UsdPrimvarReader varname was stripped from the
   anonymized network.

2. Recognize primvar-reader nodes generically (hdMtlx). A node is treated as a
   primvar reader when its implementation nodegraph wraps a geompropvalue or
   geompropvalueuniform node. New helpers HdMtlxIsPrimvarReaderNodeDef,
   HdMtlxGetPrimvarNameInputName and HdMtlxGetPrimvarDefaultInputName discover
   this and the input names that carry the primvar name and fallback (read from
   the interfacename on the wrapped geompropvalue inputs, for example varname
   and fallback for UsdPrimvarReader). These drive three call sites that
   previously only understood the native geompropvalue node by category or by
   the hardcoded geomprop/default parameter names:
     - _IsTopologicalShader now treats any primvar-reader node as topological.
     - _AddMaterialXNode now registers primvar-reader nodes in hdPrimvarNodes
       so the primvar is declared and bound.
     - _UpdatePrimvarNodes now extracts the primvar name and fallback from the
       correct inputs instead of assuming geomprop/default.
   Detecting by implementation structure rather than by family name keeps this
   robust for any future node that wraps a geompropvalue. Over-preserving a
   parameter is always correctness-safe; the only cost is slightly reduced
   shader reuse for such nodes, matching how the native geompropvalue node is
   already handled.

3. Emit glslfx-compatible primvar types (hdSt/materialXShaderGen.cpp). The
   primvar attributes block of the generated glslfx took its type name from the
   target shader language syntax. On Metal that produced names like float2,
   which HioGlslfxConfig does not understand (it accepts float, double, int,
   vec2, vec3, vec4), so the primvar declaration was rejected, st fell back to
   a default, and texture coordinates were lost (surfaces rendered untextured).
   The attributes type is now mapped to a glslfx type independent of the target
   language. This is a Metal-specific defect that became reachable only once a
   primvar actually reached shader generation.
@ld-kerley ld-kerley changed the title Support MaterialX UsdPrimvarReader in Storm [Apple] Support MaterialX UsdPrimvarReader in Storm May 30, 2026
@jesschimein

Copy link
Copy Markdown
Collaborator

Filed as internal issue #USD-12267

(This is an automated message. See here for more information.)

@dsyu-pixar dsyu-pixar moved this to On Deck in Public Backlog Jun 7, 2026
@dsyu-pixar dsyu-pixar moved this from On Deck to In Progress in Public Backlog Jul 12, 2026
@pixar-oss pixar-oss closed this in d8f217f Jul 14, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Public Backlog Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants