-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
WebGPURenderer: Tree shaking Materials - WIP #28328
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
base: dev
Are you sure you want to change the base?
Conversation
|
Maybe we can have two different builds: The first one will include classic materials and will not be fully tree-shakeable. That way... People that want to start using WebGPU would just need to replace And people that want to use WebGPU and also be able to fully tree-shake will be able to do so by using What do you think? |
|
It seems what @mrdoob has been suggested in #28328 (comment) has been implemented by other PRs. Is this PR still required? |
|
Although some ideas in this PR have been merged, the base materials were not ported to Today, materials like If In this sense, we can think the same way for lights, and so on, then we will have a complete shader abstraction and we can discard Example: import { MyLight } from 'custom-light'
scene.add( new MyLight() ); |
Introduce
The objective of the PR is to advance the tree shaking of
WebGPURendererrelated toMaterials, any suggestions and opinions regarding the notes below are welcome.Design
WebGPURenderertree shakingNodeMaterialsis very simple, the same does not happen with other library-basedMaterialabstractions such asMeshStandardMaterial, these materials depend on their shader base being accessed in theRenderer.I created
jsm/renderers/webgpu/Three.jsto have a version similar to the core related toWebGPURendererand 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
Materialclass to support the creation of shader using TSL and preserve the previous hierarchy regarding default materials.Nodeprefix in materials since it can be unified easily.Examples
webgpu_lights_selective
/cc @mrdoob @Mugen87