ShadowNode: Add support for renderer.highPrecision#33246
Merged
sunag merged 2 commits intomrdoob:devfrom Mar 29, 2026
Merged
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
shotamatsuda
commented
Mar 26, 2026
| const shadowPosition = lightShadowMatrix( light ).mul( shadowPositionWorld.add( normalWorld.mul( normalBias ) ) ); | ||
| let shadowPosition; | ||
|
|
||
| if ( ! renderer.highPrecision || builder.material.receivedShadowPositionNode || builder.context.shadowPositionWorld ) { |
Contributor
Author
There was a problem hiding this comment.
Just skipping the high precision path when receivedShadowPositionNode or a context value overrides shadowPositionWorld, though it's not ideal.
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.
Related issue: #30955
Description
This PR multiplies the light shadow matrix and object world matrix on the CPU when
renderer.highPrecisionis enabled.This is the shadow maps equivalent of the issue #30955. Shadow maps become unusable at a large distance from the origin (and relatively at a small scale) in WebGPURenderer, because
ShadowNodeuses world positions multiplied on the GPU. WebGLRenderer has no such issue.Alternatives
We could use a custom shadow node on the user side, but this is not very feasible because
ShadowNodeis not a leaf class here.Doing world origin rebasing would surely solve this precision issue, but the purpose of
renderer.highPrecisionis to handle such use cases where world origin rebasing is difficult to implement for various reasons, with some performance trade off.--
Results with a torus knot with a diameter of 1 at 6e6 away from the origin, with
renderer.highPrecisionenabled for all cases.