arnold-usd icon indicating copy to clipboard operation
arnold-usd copied to clipboard

Sdr node discovery results should be consistent across renderers

Open JGamache-autodesk opened this issue 3 years ago • 0 comments

Describe the bug

We are looking for consistency in the way shader nodes are registered. This will allow a node editor to build a nicer node picker by grouping nodes according to hints provided in the registration. Having a consistent registration scheme will allow all renderer nodes to be sorted without needing custom per-renderer coding in the DCC.

To Reproduce

  1. In a USD python session, with the arnold-usd binaries added to PXR_PLUGINPATH_NAME, run the following script:
for id1,id2,id3 in (("arnold:standard_surface", "ND_standard_surface_surfaceshader", "UsdPreviewSurface"),
                    ("arnold:rgb_to_float",  "ND_mix_color3", "UsdPrimvarReader_float2")):
    n1 = Sdr.Registry().GetShaderNodeByIdentifier(id1)
    n2 = Sdr.Registry().GetShaderNodeByIdentifier(id2)
    n3 = Sdr.Registry().GetShaderNodeByIdentifier(id3)
    print("Identifier", n1.GetIdentifier(), n2.GetIdentifier(), n3.GetIdentifier())
    print("Name", n1.GetName(), n2.GetName(), n3.GetName())
    print("Family", n1.GetFamily(), n2.GetFamily(), n3.GetFamily())
    print("Role", n1.GetRole(), n2.GetRole(), n3.GetRole())
    print("Context", n1.GetContext(), n2.GetContext(), n3.GetContext())
    print("SourceType", n1.GetSourceType(), n2.GetSourceType(), n3.GetSourceType())
    print()

You will get the following output:

Identifier arnold:standard_surface ND_standard_surface_surfaceshader UsdPreviewSurface
Name       standard_surface        ND_standard_surface_surfaceshader UsdPreviewSurface
Family     shader                  standard_surface                  UsdPreviewSurface
Role       standard_surface        pbr                               UsdPreviewSurface
Context    arnold                  surface                           usda
SourceType arnold                  mtlx                              glslfx

Identifier arnold:rgb_to_float ND_mix_color3 UsdPrimvarReader_float2
Name       rgb_to_float        ND_mix_color3 UsdPrimvarReader_float2
Family     shader              mix           UsdPrimvarReader
Role       rgb_to_float        compositing   primvar
Context    arnold              pattern       usda
SourceType arnold              mtlx          glslfx

Expected behavior

We would expect the family to be the same as the name. The specifications are vague, but the USD and NdrFsHelpersSplitShaderIdentifier() implementations allow us to deduce that shaders that differ only by output type should be in the same family.

Role is less strictly defined, it groups nodes by "nodegroup" in MaterialX and seems to also get a generic category for USD native shaders. Maybe it could be something similar to the classification used to build the shader nodes documentation page in Arnoldopedia.

We might want to leave Context untouched. For MaterialX everything is a pattern, except surface/displacement/volume shaders where the context reflects the expected terminal node to connect on the material.

Screenshots

Used Software Versions

  • Arnold: 7.1.3.0
  • USD: 22.5

Additional context

JGamache-autodesk avatar Jul 13 '22 16:07 JGamache-autodesk