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

WebGPURenderer: Tree shaking Materials - WIP #28328

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

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented May 10, 2024

Introduce

The objective of the PR is to advance the tree shaking of WebGPURenderer related to Materials, any suggestions and opinions regarding the notes below are welcome.

Design

WebGPURenderer tree shaking NodeMaterials is very simple, the same does not happen with other library-based Material abstractions such as MeshStandardMaterial, these materials depend on their shader base being accessed in the Renderer.

image

I created jsm/renderers/webgpu/Three.js to have a version similar to the core related to WebGPURenderer and three shaking.

The code below shows the two examples related to the image mentioned above:

WebGLRenderer - Core
https://github.com/sunag/three.js/blob/dev-materials/src/materials/MeshStandardMaterial.js

WebGPURenderer - Core
https://github.com/sunag/three.js/blob/dev-materials/examples/jsm/materials/MeshStandardMaterial.js

The main difference is that we have some added setup*() calls and extends NodeMaterial.

Thoughts

  • Structure Material class to support the creation of shader using TSL and preserve the previous hierarchy regarding default materials.
  • We would no longer need the Node prefix in materials since it can be unified easily.

Examples

webgpu_lights_selective

/cc @mrdoob @Mugen87

@sunag sunag changed the title WebGPURenderer: Tree shaking Materials WebGPURenderer: Tree shaking Materials - WIP May 10, 2024
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.

None yet

1 participant