Fix shadows of long range OmniLight3D
and SpotLight3D
#100319
Merged
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.
This PR allows omni and spotlights with range greater than a few hundreds of meters to keep casting shadows on nearby objects.
Currently, nearby objects get culled against the light's near plane which grows with the range. There is also a numerical precision issue encountered when large zfar (which is equal to the range) is retrieved from the light's projection matrix to blit the cubemap.
With this PR and the default bias of 0.1 (equivalent of 0.001 for
SpotLight3D
), ranges up to ~6km in Cubemap mode now render shadows without artifacts.Higher biases even allow much higher ranges.
Note : DP mode seems to allow much larger ranges than Cubemap without artifacts. I suspect further numerical precision issues in the cube-to-dp copy effect. It may be the subject for another PR.
Fixes #96361
Fixes #92551