Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaterialX: Storm fails to reuse GLSL shaders for networks differing only on node names #2330

Closed
JGamache-autodesk opened this issue Mar 13, 2023 · 1 comment

Comments

@JGamache-autodesk
Copy link
Contributor

Description of Issue

The function HdSt_MaterialNetworkShader::CanAggregate() will compare the hash of the GLSL shader text to know if it can aggregate two material networks.

MaterialX will use the node names when generating a uniform variable name when there are connected ancillary nodes. If these node names vary, the hash will differ and the merging will fail.

Steps to Reproduce

  1. Load attached scene in USDView goldRamp.zip
    [BUG] compiles 11 GLSL shaders where only one would be needed

The scene was designed to show the issue by having a ND_dot_float with a varying name connected in exactly the same way on each surface.

Potential fix

One option would be to anonymize the node names in the network so they follow a consistent scheme. This will harmonize the uniform parameter names and allow more material networks to reuse the same shader.

System Information (OS, Hardware)

Package Versions

Build Flags

@sunyab
Copy link
Contributor

sunyab commented Mar 14, 2023

Filed as internal issue #USD-8091

erikaharrison-adsk pushed a commit to autodesk-forks/USD that referenced this issue May 6, 2024
Fixes:

- MaterialX: Storm fails to reuse GLSL shaders for networks differing only on node names PixarAnimationStudios#2330
- Storm shader compilation errors when using MaterialX triplanarprojection node. PixarAnimationStudios#3004
- Improve transparency detection and fix generation

Using a topo-trimmed network resulted in all shaders being generated
with opaque semantics. The shaders are now created with the right
transparent hardware settings.

Also improved transparency detection at the _GetMaterialTag level by
adding more checks for known surfaces and delegating to MaterialX when
dealing with custom shaders, but without generating the full MaterialX
document.
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

No branches or pull requests

2 participants