Description of Issue
The MaterialX <displacement> construct can either be a float scalar or a vector3 vector[1] which should end up resolving to either a ND_displacement_float or a ND_displacement_vector3 respectively[2].
However, it looks like the USD MaterialX reader doesn't take the input type into account and always assigns scalar float displacement as ND_displacement_vector3
[1] https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/documents/Specification/MaterialX.Specification.md#standard-library-shader-nodes
[2] See the nodedefs inside: https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/pbrlib/pbrlib_defs.mtlx
Steps to Reproduce
- Given the following MaterialX document:
<?xml version="1.0"?>
<materialx version="1.38">
<displacement name="Displacement" type="displacementshader">
<input name="displacement" type="float" value="0.5" />
<input name="scale" type="float" value="0.1" />
</displacement>
<surfacematerial name="TestMaterial" type="material">
<input name="displacementshader" type="displacementshader" nodename="Displacement" />
</surfacematerial>
</materialx>
- Observe what happens while loading it -- here I'm also using
TF_DEBUG=USDMTLX_READER
MaterialX::DocumentPtr mtlx_doc = MaterialX::createDocument();
MaterialX::readFromXmlFile(mtlx_doc, "t:/scalar-displace.mtlx");
pxr::UsdStageRefPtr stage = pxr::UsdStage::CreateInMemory();
pxr::UsdMtlxRead(mtlx_doc, stage, pxr::SdfPath("/root"));
Output:
Adding mtlxMaterial 'TestMaterial'
Adding shaderNode 'Displacement' type: 'displacementshader'
Created shader mtlx ND_displacement_vector3, as usd ND_displacement_vector3
Add shader output out of type displacementshader
Coding Error: in _SetValueImpl at line 6725 of C:\db\build\S\VS1564R\build\usd\src\external_usd\pxr\usd\usd\stage.cpp -- Type mismatch for </root/Materials/TestMaterial.inputs:displacement>: expected 'GfVec3f', got 'float'
System Information (OS, Hardware)
Package Versions
- USD 24.05 / MaterialX 1.38.8
Build Flags
- A rather basic monolithic build
Description of Issue
The MaterialX
<displacement>construct can either be a float scalar or a vector3 vector[1] which should end up resolving to either aND_displacement_floator aND_displacement_vector3respectively[2].However, it looks like the USD MaterialX reader doesn't take the input type into account and always assigns scalar float displacement as
ND_displacement_vector3[1] https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/documents/Specification/MaterialX.Specification.md#standard-library-shader-nodes
[2] See the nodedefs inside: https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/pbrlib/pbrlib_defs.mtlx
Steps to Reproduce
TF_DEBUG=USDMTLX_READEROutput:
System Information (OS, Hardware)
Package Versions
Build Flags