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

WebGLShadowMap: Support alphaToCoverage with shadows. #30871

Merged
merged 1 commit into from
Apr 6, 2025

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Apr 5, 2025

Fixed #30462.

Description

Materials might use alphaToCoverage to implement grass sprites/billboards like mentioned in #30462. WebGLRenderer is currently not able to provide proper shadows with such a setup. alphaToCoverage can only be used in a multisampled context which is not true for shadow map generation. So the idea is to approximate shadows like suggested by #30760. This PR implements a different approach with less changes in WebGLShadowMap. The shared codesandbox in #30760 (comment) is fixed with this change.

Copy link

github-actions bot commented Apr 5, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.44
78.37
336.49
78.38
+50 B
+9 B
WebGPU 541.97
150.12
541.97
150.12
+0 B
+0 B
WebGPU Nodes 541.44
150.01
541.44
150.01
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.37
112.21
465.42
112.22
+50 B
+11 B
WebGPU 614.81
166.16
614.81
166.16
+0 B
+0 B
WebGPU Nodes 569.8
155.56
569.8
155.56
+0 B
+0 B

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Apr 5, 2025

I've tried adding this fix for WebGPURenderer as well. However, even materials with just alphaTest are not yet supported (shadows extend uniformly over the entire plane) so more updates are required in WebGPURenderer. Better to do this with a separate PR.

Reproduction test: https://jsfiddle.net/Lt1d32m7/

@Mugen87 Mugen87 added this to the r176 milestone Apr 6, 2025
@Mugen87 Mugen87 merged commit e3ee968 into mrdoob:dev Apr 6, 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.

Allow shadows to use alphaToCoverage.
1 participant