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

Shadows disappear at certain viewing angles with distant camera far plane #91753

Closed
minoaut opened this issue May 9, 2024 · 7 comments
Closed

Comments

@minoaut
Copy link

minoaut commented May 9, 2024

Tested versions

Reproducible in: v4.3.dev.custom_build [7ebc866]
Not reproducible in: v4.3.dev.custom_build [51991e2]
Regression introduced in: v4.3.dev.custom_build [4577dfd]

System information

Ubuntu 24.04 LTS - Vulkan (Forward+) - reproducible with both Intel IGP and NVIDIA dedicated

Issue description

If the Camera3D far plane is set to something high like 1e5..1e6, shadows disappear at certain viewing angles either completely or partially. The affected angles are narrow, but once found and the camera stays put, shadows can stay off indefinitely.

Shadows may disappear partially. In my project, trees (MultimeshInstance) are often unaffected, but not always, while all vehicles and terrain lose their shadows regularly. Where shadows disappear they all disappear at the same time, no matter the object type or distance.

Shadow settings seem to have no influence on this. The only setting that I found to have an impact is the camera far plane:
far = 4000 (default) -> cannot reproduce
far = 1e5 -> can reproduce at few angles
far = 1e6 -> can reproduce at many angles

I happen to need at least 1e5, better 1e6, else the clouds don't render right.

Steps to reproduce

  • Run the attached sample project
  • observe for a few seconds (10-30s)
  • shadows should disappear briefly at multiple rotation angles
    look for whole walls flashing bright white

Minimal reproduction project (MRP)

disappearing_shadows_example.zip

@minoaut
Copy link
Author

minoaut commented May 11, 2024

I let git bisect do it's thing and it found this commit:
4577dfd is the first bad commit

With that commit shadows start to disappear.

@minoaut
Copy link
Author

minoaut commented May 11, 2024

Here's the workaround I'm using now,. It's terrible, don't commit.
I'm not sure what the real issue is. Maybe the frustum planes don't factor in the changed far plane for some reason?

diff --git a/servers/rendering/rendering_light_culler.cpp b/servers/rendering/rendering_light_culler.cpp
index 8dc2d85bdf..0d8a6d90ce 100644
--- a/servers/rendering/rendering_light_culler.cpp
+++ b/servers/rendering/rendering_light_culler.cpp
@@ -418,7 +418,7 @@ bool RenderingLightCuller::_add_light_camera_planes(LightCullPlanes &r_cull_plan
 	// Deal with special case... if the light is INSIDE the view frustum (i.e. all planes face away)
 	// then we will add the camera frustum planes to clip the light volume .. there is no need to
 	// render shadow casters outside the frustum as shadows can never re-enter the frustum.
-	if (lookup == 63) {
+	if (1 || lookup == 63) {
 		r_cull_planes.num_cull_planes = 0;
 		for (int n = 0; n < data.frustum_planes.size(); n++) {
 			r_cull_planes.add_cull_plane(data.frustum_planes[n]);

@Chaosus
Copy link
Member

Chaosus commented May 11, 2024

cc @lawnjelly

@lawnjelly
Copy link
Member

Likely duplicate of #89560 , so may be fixed already.
Cannot test as away from home.

@lawnjelly
Copy link
Member

Yes I can confirm this is already fixed by #91790 .

I'll close this issue and reopen #89560 temporarily to hopefully reduce the chance of duplicate issues.

@Chaosus Chaosus removed this from the 4.3 milestone May 12, 2024
@minoaut

This comment was marked as resolved.

@lawnjelly

This comment was marked as resolved.

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

No branches or pull requests

3 participants