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

Fix shadows of long range OmniLight3D and SpotLight3D #100319

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

Flarkk
Copy link
Contributor

@Flarkk Flarkk commented Dec 12, 2024

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

@Flarkk Flarkk requested a review from a team as a code owner December 12, 2024 14:51
@Flarkk Flarkk changed the title Fix shadows of large range point lights Fix shadows of large range OmniLight3D and SpotLight3D Dec 12, 2024
@Flarkk Flarkk changed the title Fix shadows of large range OmniLight3D and SpotLight3D Fix shadows of long range OmniLight3D and SpotLight3D Dec 12, 2024
@Calinou Calinou added bug topic:rendering topic:3d cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release labels Dec 12, 2024
@Calinou Calinou added this to the 4.4 milestone Dec 12, 2024
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Makes sense to me. A fixed z_near is going to be worse for distant shadows of lights with huge ranges. But, it is certainly better than having the shadow simply disappear.

@clayjohn clayjohn removed the cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release label Dec 13, 2024
@Repiteo Repiteo merged commit dc5f1b7 into godotengine:master Dec 13, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 13, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants