WebGPURenderer: Tree shaking Materials - WIP #28328
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduce
The objective of the PR is to advance the tree shaking of
WebGPURenderer
related toMaterials
, any suggestions and opinions regarding the notes below are welcome.Design
WebGPURenderer
tree shakingNodeMaterials
is very simple, the same does not happen with other library-basedMaterial
abstractions such asMeshStandardMaterial
, these materials depend on their shader base being accessed in theRenderer
.I created
jsm/renderers/webgpu/Three.js
to have a version similar to the core related toWebGPURenderer
and three shaking.The code below shows the two examples related to the image mentioned above:
WebGLRenderer
- Corehttps://github.com/sunag/three.js/blob/dev-materials/src/materials/MeshStandardMaterial.js
WebGPURenderer
- Corehttps://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 extendsNodeMaterial
.Thoughts
Material
class to support the creation of shader using TSL and preserve the previous hierarchy regarding default materials.Node
prefix in materials since it can be unified easily.Examples
webgpu_lights_selective
/cc @mrdoob @Mugen87