Skip to content

Conversation

@Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Sep 5, 2024

Related issue: #29295

Description

This PR adds a version of ShadowMapViewer that is compatible with WebGPURenderer.

@Mugen87 Mugen87 added this to the r169 milestone Sep 5, 2024
//always end up with the scene's first added shadow casting light's shadowMap
//in the shader
//See: https://github.com/mrdoob/three.js/issues/5932
shadowMapUniform.value = light.shadow.map.texture;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Shadow maps are implemented differently in WebGPURenderer since they use depth textures and don't rely on MeshDepthMaterial. Hence, the debug texture looks a bit different since we use the shadow color for visualization purposes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Mugen87 Do you, by chance, have a fiddle showing this helper being used, and rendering some representation of shadow camera depth correctly? 🙏

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Mugen87 The helper is rendering black for me. A quick example would be greatly appreciated. I am hoping this helper can verify if the full extent of the depth range is being used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe there is a regression since we don't have a dedicated example yet. How about we add a copy of webgl_shadowmap_viewer and name it webgpu_shadowmap_viewer. When then have some sample code for testing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK. So to confirm, we don't render the depthTexture directly, but the shadow.map.texture, instead? And the texture should display a grayscale image of depth in [0, 1]?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we don't render the depthTexture directly, but the shadow.map.texture, instead?

Yes. But to be honest I don't know anymore how the visualized texture looks like. Maybe it was just a black cutout.

@github-actions
Copy link

github-actions bot commented Sep 5, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 685.18
169.62
685.18
169.62
+0 B
+0 B
WebGPU 826
221.45
826.02
221.46
+24 B
+7 B
WebGPU Nodes 825.58
221.36
825.61
221.36
+443 B
+101 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 461.96
111.46
461.96
111.46
+0 B
+0 B
WebGPU 525.25
141.51
525.27
141.52
+24 B
+7 B
WebGPU Nodes 481.9
131.33
481.93
131.34
-43.32 kB
+9 B

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.

2 participants