Binding MaterialX to SceneIndex

Hi

I’m looking for some help with binding MaterialX based hdnetwork to my sceneindex
I’ve this mtlx document successfully converted to a hdDataSource as below:
Note: I’m setting the HdMaterialSchema::BuildRetained to use mtlx instead of HdMaterialSchemaTokens->universalRenderContext

[mtlx]
        [nodes]
                [/MaterialX/Materials/USD_Plastic/ND_UsdPreviewSurface_surfaceshader]
                        [inputConnections]
                        [nodeIdentifier]
                                ND_UsdPreviewSurface_surfaceshader
                        [parameters]
                                [diffuseColor]
                                        [value]
                                                (0.10470402, 0.24188282, 0.818)
                                [ior]
                                        [value]
                                                1.5
                                [roughness]
                                        [value]
                                                0.32467532
        [terminals]
                [surface]
                        [upstreamNodeOutputName]
                                surface
                        [upstreamNodePath]
                                /MaterialX/Materials/USD_Plastic/ND_UsdPreviewSurface_surfaceshader

I’m adding it to my sceneindex as below:

pxr::SdfPath materialId("/MaterialX/Materials/USD_Plastic");
retainedScene->AddPrims({ { materialId, TfToken("materials"), mtlxdata } });

My Scene Index contents are:

/ ()
/teapot ()
/teapot/lid (mesh)
  @mesh:
    @topology:
      @faceVertexCounts: [...]
      @faceVertexIndices: [...]
      @holeIndices: []
      @orientation: rightHanded
  @primvars:
    @points:
      @primvarValue: [...]
      @indices: []
      @interpolation: vertex
      @role: point
    @normals:
      @primvarValue: [...]
      @indices: []
      @interpolation: vertex
      @role: normal
    @displayColor:
      @primvarValue: (1, 0, 0)
      @indices: []
      @interpolation: constant
      @role: color
  @materialBindings:
    @:
      @path: /MaterialX/Materials/USD_Plastic
/teapot/body (mesh)
  @mesh:
    @topology:
      @faceVertexCounts: [...]
      @faceVertexIndices: [...]
      @holeIndices: []
      @orientation: rightHanded
  @primvars:
    @points:
      @primvarValue: [...]
      @indices: []
      @interpolation: vertex
      @role: point
    @normals:
      @primvarValue: [...]
      @indices: []
      @interpolation: vertex
      @role: normal
    @displayColor:
      @primvarValue: (1, 0, 0)
      @indices: []
      @interpolation: constant
      @role: color
  @materialBindings:
    @:
      @path: /MaterialX/Materials/USD_Plastic
/MaterialX ()
/MaterialX/Materials ()
/MaterialX/Materials/USD_Plastic (materials)
  @mtlx:
    @nodes:
      @/MaterialX/Materials/USD_Plastic/ND_UsdPreviewSurface_surfaceshader:
        @parameters:
          @diffuseColor:
            @value: (0.10470402, 0.24188282, 0.818)
          @ior:
            @value: 1.5
          @roughness:
            @value: 0.32467532
        @inputConnections:
        @nodeIdentifier: ND_UsdPreviewSurface_surfaceshader
    @terminals:
      @surface:
        @upstreamNodePath: /MaterialX/Materials/USD_Plastic/ND_UsdPreviewSurface_surfaceshader
        @upstreamNodeOutputName: surface

I’m unable to get mtlx shaders to work. Looking at HydraBrowser I see the same datasource layout
Any ideas what I’m missing here?

Here is what I see in Hydra Browser using this test asset:


Comparing this to the USD Scene Index Emulation this is what I see:

/MaterialX/Materials/USD_Plastic (material)
  (@primvars)
  @material:
    @:
      @nodes:
        @/MaterialX/Materials/USD_Plastic/ND_UsdPreviewSurface_surfaceshader:
          @parameters:
            @diffuseColor:
              @value: (0.10470402, 0.24188282, 0.818)
            @ior:
              @value: 1.5
            @roughness:
              @value: 0.32467532
          @inputConnections:
          @nodeIdentifier: ND_UsdPreviewSurface_surfaceshader
      @terminals:
        @surface:
          @upstreamNodePath: /MaterialX/Materials/USD_Plastic/ND_UsdPreviewSurface_surfaceshader
          @upstreamNodeOutputName: surface
  @sceneDelegate: 0000019665B739D0

How do I get the additional

  (@primvars)
  @material:

I think I got this to work. Needed to build a material container :exploding_head: and stick all of the datasource into it.