Renderer: Shadow map improvements.#32705
Merged
Mugen87 merged 5 commits intomrdoob:devfrom Jan 11, 2026
Merged
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
Mugen87
commented
Jan 10, 2026
|
|
||
| // dp = normalized distance from light to fragment position | ||
| const dp = lightToPositionLength.sub( cameraNearLocal ).div( cameraFarLocal.sub( cameraNearLocal ) ).toVar(); // need to clamp? | ||
| const dp = viewZToPerspectiveDepth( viewZ.negate(), shadowCameraNear, shadowCameraFar ); |
Collaborator
Author
There was a problem hiding this comment.
I think the usage of viewZToPerspectiveDepth() makes much more clear what's going on in this function.
Mugen87
commented
Jan 10, 2026
|
|
||
| overrideMaterial.side = ( material.shadowSide !== null ) ? material.shadowSide : _shadowSide[ material.side ]; | ||
|
|
||
| } |
Collaborator
Author
There was a problem hiding this comment.
This block here is the most important fix. It eliminates the shadow acne that has been reported over months, including #32698.
Collaborator
Author
|
With this change, many WebGPU demos using shadows don't need a shadow bias anymore. When this is merged, I'll go trough all of them and remove the bias if possible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixed #32698.
Description
After reviewing the shadow code base and an in-depth WebGL state comparison between the reproduction test cases from #32698, I'm confident to change the following:
WebGPURenderer, the shadow side wasn't configured correctly which was the main reasons for the extreme shadow acne.WebGLRenderer,vogelDiskSample()was redundantly called in the point light code path. The sample values are now computed once and shared like inWebGPURendererwhich improves performance.WebGPURenderer, the depth textures for PCF (Soft) shadows must useLinearFilter. This noticeably improves shadow quality which you can see in the SSS demo.WebGPURenderer, blending should be disabled when rendering shadows (similar toWebGLRenderer). This improves performance a bit.WebGPURenderer, the precision for all shadow samplers should behighpfor consistency withWebGLRenderer.WebGPURenderer, the compare functionLessEqualis now used to matchWebGLRenderer.WebGPURenderer, the point light shadow code can be significantly simplified.