-
Notifications
You must be signed in to change notification settings - Fork 411
Description
This issue is split from #1871.
The shader generators do not generate the correct code when two nodes have the same name inside two different nodegraphs.
It produces no errors, but a wrong render result.
Apparently this affects all backends. We confirmed it for MDL, GLSL and OSL in MaterialX 1.39.4.
I attached two example mtlx files in the zip: nodenames-example-mtlx.zip
Each material has 2 compounds. Both compounds contain a crosshatch node.
The only difference between the files is the naming of the crosshatch nodes:
- 2x-crosshatch-diffName.mtlx -- correct rendering (names: crosshatch1 and crosshatch2)
- 2x-crosshatch-sameName.mtlx -- broken rendering (names: crosshatch1 and crosshatch1)
After PR #2768, the render result is unchanged. One difference to 1.39.4 is that the generated shader code now calls NG_crosshatch_color3 twice instead of once, but both calls use identical parameters. I verified this behavior in both MDL and GLSL. For example, in MDL the generated code now looks like this:
color crosshatch1_out = NG_crosshatch_color3(geomprop_UV0_out1, crosshatch1_uvtiling, crosshatch1_uvoffset, crosshatch1_thickness, crosshatch1_staggered);
color crosshatch1_out1 = NG_crosshatch_color3(geomprop_UV0_out1, crosshatch1_uvtiling, crosshatch1_uvoffset, crosshatch1_thickness, crosshatch1_staggered);
The two crosshatch nodes in the have different input values though (different uvtiling, uvoffset, thickness, and staggered values).
So the end result is the same as before with 1.39.4.
A workaround on the application side is to set globally unique node names on the MaterialX document before passing to the shader generator. Of course we would prefer not needing to apply this workaround.
For reference, this is how the rendering looks in the MaterialXGraphEditor.
The blue one is the correct render result:

Wrong rendering:
