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

RenderObject: Improve cache key computation when rendering shadows. #30316

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jan 13, 2025

Fixed #30065.

Description

When WebGPURenderer is inside a shadow pass, the dynamic cache key computation in RenderObject can be drastically simplified. The "expensive" part Nodes.getCacheKey() can be completely skipped since this key represents the environment of the scene (lighting, environment map, fog and background) which is irrelevant when rendering shadow maps.

Copy link

github-actions bot commented Jan 13, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 339.52
79.1
339.52
79.1
+0 B
+0 B
WebGPU 490.81
136.38
490.85
136.4
+46 B
+15 B
WebGPU Nodes 490.27
136.28
490.32
136.29
+46 B
+15 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465.41
112.15
465.41
112.15
+0 B
+0 B
WebGPU 561.38
152.09
561.43
152.11
+46 B
+16 B
WebGPU Nodes 516.77
141.66
516.82
141.68
+46 B
+16 B

@RenaudRohlinger
Copy link
Collaborator

Awesome!!

@@ -56,7 +56,7 @@ const getShadowMaterial = ( light ) => {
material = new NodeMaterial();
material.colorNode = vec4( 0, 0, 0, 1 );
material.depthNode = depthNode;
material.isShadowNodeMaterial = true; // Use to avoid other overrideMaterial override material.colorNode unintentionally when using material.shadowNode
material.isShadowPassMaterial = true; // Use to avoid other overrideMaterial override material.colorNode unintentionally when using material.shadowNode
Copy link
Collaborator Author

@Mugen87 Mugen87 Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR renames the type property to the more generic isShadowPassMaterial since isShadowNodeMaterial is reserved by ShadowNodeMaterial.

@Mugen87 Mugen87 added this to the r173 milestone Jan 14, 2025
@Mugen87 Mugen87 merged commit 0434326 into mrdoob:dev Jan 14, 2025
12 checks passed
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.

WebGPURenderer: Shadows Performances Issues
2 participants