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

Autodesk: Generate optimal MaterialX shaders via lobe pruning #3525

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

erikaharrison-adsk
Copy link
Contributor

Description of Change(s)

Introduces the lobe pruning concept to MaterialX shaders generated by Storm

We look into shader graph implemnetation and find where we can cut the graph to simplify it based on the value of the main lobe attributes.

This means a shader with a subsurface weight of zero will completely prune the evaluation of the subsurface, while a value of 1 will completely prune the evaluation of the dielectric base.

This provides interesting performance values:

Playback of a rotating 11x11x11 cube of cubes in usdView:

Before:
           light:    Dome   Default
UsdPreviewSurface    29fps  23fps
mx::StandardSurface  15fps  20fps
mx::OpenPBRSurface    7fps  12fps

After:
           light:    Dome   Default
mx::StandardSurface  29fps  22fps
mx::OpenPBRSurface   29fps  22fps

Looks refresh-limited, better test rig required.

Technical side: The code looks for nodes in the nodegraph implementation and checks any node that directly connects to the interface on a 0-1 slider:

  • Mix nodes: If the mix value if 0 or 1, forward the value/connection of the bg or fg port to the node directly upstream. Delete node.
  • Multiply nodes: If any value is zero, write zero to the corresponding port on the upstream node. Delete node.
  • PBR nodes: If the weight parameter is zero, substitute with a no-op PBR node. Delete node.

This makes sure the ShaderGen works on a reduced codebase and greatly reduces code size and complexity by disconnecting unused subgraphs and skipping black PBR calls.

Link to proposal (if applicable)

  • N/A

Fixes Issue(s)

  • N/A

Checklist

Introduces the lobe pruning concept to MaterialX shaders generated by
Storm

We look into shader graph implemnetation and find where we can cut the graph to simplify it based on the value of the main lobe attributes.

This means a shader with a subsurface weight of zero will completely prune the evaluation of the subsurface, while a value of 1 will completely prune the evaluation of the dielectric base.

This provides interesting performance values:
```
Playback of a rotating 11x11x11 cube of cubes in usdView:

Before:
           light:    Dome   Default
UsdPreviewSurface    29fps  23fps
mx::StandardSurface  15fps  20fps
mx::OpenPBRSurface    7fps  12fps

After:
           light:    Dome   Default
mx::StandardSurface  29fps  22fps
mx::OpenPBRSurface   29fps  22fps
```

Looks refresh-limited, better test rig required.

Technical side: The code looks for nodes in the nodegraph implementation and checks any node that directly connects to the interface on a 0-1 slider:

- Mix nodes: If the mix value if 0 or 1, forward the value/connection of the bg or fg port to the node directly upstream. Delete node.
- Multiply nodes: If any value is zero, write zero to the corresponding port on the upstream node. Delete node.
- PBR nodes: If the weight parameter is zero, substitute with a no-op PBR node. Delete node.

This makes sure the ShaderGen works on a reduced codebase and greatly reduces code size and complexity by disconnecting unused subgraphs and skipping black PBR calls.
@erikaharrison-adsk erikaharrison-adsk changed the title Generate optimal MaterialX shaders via lobe pruning Autodesk: Generate optimal MaterialX shaders via lobe pruning Feb 6, 2025
Will also fix other case sensitive OS.
@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10661

(This is an automated message. See here for more information.)

@jesschimein
Copy link
Collaborator

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

Successfully merging this pull request may close these issues.

3 participants