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

Directional Shadows disappear with large Camera Z Far values at some angles #89560

Closed
ashlanderr opened this issue Mar 16, 2024 · 6 comments · Fixed by #91790
Closed

Directional Shadows disappear with large Camera Z Far values at some angles #89560

ashlanderr opened this issue Mar 16, 2024 · 6 comments · Fixed by #91790

Comments

@ashlanderr
Copy link

Tested versions

  • Reproducible in: v4.3.dev5.official [89f70e9]
  • Not Reproducible in: v4.3.dev2.official [3524346], v4.2.1.stable.mono.official [b09f793]

System information

Godot v4.3.dev5 - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 Ti (NVIDIA; 31.0.15.3623) - AMD Ryzen 7 2700 Eight-Core Processor (16 Threads)

Issue description

When I set the camera's Z Near to 10m and Z Far to 1,000,000m, shadows from a directional light begin to disappear at certain angles. Reducing the Z Far value to 100,000m resolves the issue. The ratio between the near and far planes is not significantly different from the default values (4000 / 0.05 = 80,000, compared to 1,000,000 / 10 = 100,000), so I think that the problem is unlikely to be related to Z fighting or similar issues.

Small Z Far value:
image

Large Z Far value:
image

Steps to reproduce

In the MRP, toggle the preview between Camera3D_Ok and Camera3D_Error to observe the disappearance of shadows. Additionally, you can adjust the editor camera settings to match those of Camera3D_Error and rotate it to identify angles at which the shadows fail.

Minimal reproduction project (MRP)

ShadowTest1.zip

@matheusmdx
Copy link
Contributor

Bisecting points to #84745 as the culprit

image

@clayjohn
Copy link
Member

clayjohn commented May 9, 2024

Cc @lawnjelly

@lawnjelly
Copy link
Member

lawnjelly commented May 10, 2024

I just checked and it doesn't seem fixed by #89714 which was merged after 4.3 dev 5.

It's probably again down to numerical precision at large values, I'll investigate, it could be it needs an epsilon for this case.

Until then just switch off tighter culling in project_settings/rendering/lights_and_shadows/tighter_shadow_caster_culling if you wish to use extreme frustum sizes.

@lawnjelly
Copy link
Member

Also occurs in 3.6 beta 5 (as the tighter culling code is shared). Here's MRP for 3.6:
tighter_culling_large_frustum_bug.zip

This should be easier to debug in 3.6 and port fix to 4.x.

@lawnjelly
Copy link
Member

Got it, it's the same bug as #89714 , but I forgot to fix it for directional lights.
Should be able to do PR quickly before I go, as I am away this weekend.

@lawnjelly
Copy link
Member

Re-opening this temporarily (maybe until the next build) to try and prevent duplicate issues being reported.

The issue is fixed, but bug reporters may not see closed issues in their searches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Bad
Development

Successfully merging a pull request may close this issue.

5 participants