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

SpotLight3D shadows exhibit flickering when moved around. #91976

Closed
catboy-catfish opened this issue May 15, 2024 · 8 comments · Fixed by #92078
Closed

SpotLight3D shadows exhibit flickering when moved around. #91976

catboy-catfish opened this issue May 15, 2024 · 8 comments · Fixed by #92078

Comments

@catboy-catfish
Copy link

Tested versions

Only tested v4.3.dev6.mono.official [89850d5] and v4.2.2.stable.official [15073af]. Reproducible in v4.3, doesn't seem to be reproducible in v4.2.2.

System information

Godot v4.3.dev6.mono - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1650 (NVIDIA; 31.0.15.5186) - Intel(R) Core(TM) i3-6100 CPU @ 3.70GHz (4 Threads)

Issue description

The shadows from a SpotLight3D start to flicker whenever moved around in 4.3.dev6 official build. The issue can be seen more clearly in the linked video. (There are more files in the video's file browser than there are in the MRP because I didn't delete as much files beforehand.)

2024-05-15.20-18-22.mp4

Steps to reproduce

  1. Open the MRP listed below.
  2. Hit the play button.
  3. Controls - WASD: movement | Mouse: look around | Space: jump | Shift: run | Ctrl: walk slowly |

Minimal reproduction project (MRP)

flickering-shadows-mrp 4.3-dev6.zip

@lawnjelly
Copy link
Member

It might be worth turning off tighter shadow culling in project settings advanced , rendering lights and shadows, to check whether this is a regression due to tighter culling.

If so I can investigate saturday. There is currently a known bug with directional lights in dev6, but spots and omnis no bugs currently reported.

@matheusmdx
Copy link
Contributor

It might be worth turning off tighter shadow culling in project settings advanced , rendering lights and shadows, to check whether this is a regression due to tighter culling.

I can confirm disabling tighter shadow culling stops the flickering

@catboy-catfish
Copy link
Author

catboy-catfish commented May 15, 2024

It might be worth turning off tighter shadow culling in project settings advanced , rendering lights and shadows, to check whether this is a regression due to tighter culling.

If so I can investigate saturday. There is currently a known bug with directional lights in dev6, but spots and omnis no bugs currently reported.

It might be worth turning off tighter shadow culling in project settings advanced , rendering lights and shadows, to check whether this is a regression due to tighter culling.

I can confirm disabling tighter shadow culling stops the flickering

Just tried this out, it does seem to solve the flickering issue, but apparently tighter shadow caster culling can increase performance, which is exactly what I want. Maybe tighter shadow caster culling could be set separately for each light? Maybe we could add the option's 'flickering' issue in the docs.

@matheusmdx
Copy link
Contributor

@catboy-catfish Don't worry, this was just to know where the problem started, is not the final solution. As lawnjelly said this will be investigated to make work with tighter shadow culling

@catboy-catfish
Copy link
Author

@catboy-catfish Don't worry, this was just to know where the problem started, is not the final solution. As lawnjelly said this will be investigated to make work with tighter shadow culling

Cool cool, maybe I could make a proposal out of this

@lawnjelly
Copy link
Member

Re-opening as this is not fixed yet. Disabling was to identify the bug, not to fix.

@lawnjelly lawnjelly reopened this May 16, 2024
@lawnjelly
Copy link
Member

First step was making a more usable MRP, then converting to 3.x:
spotlight_tight_cull_bug.zip

@lawnjelly
Copy link
Member

lawnjelly commented May 18, 2024

Getting clues now. It seems to be due to the spotlight being attached to the camera, at 0, 0 on the y and z axis.

The light position is therefore on the exact boundary for the top and bottom camera frustum planes, and sometimes the distance check is returning +0 and sometimes -0 due to float inaccuracy.

This may need an epsilon to prevent this edge condition.

UPDATE:
It looks like this can be solved just be increasing the colinearity epsilon a bit (I did have it set to a deliberately very low value, partly because once you increase it, you never know whether it can be lower).

Whether borderline frustum planes should be considered back facing is another matter, but this seems more like a question of slightly increasing efficiency, rather than affecting accuracy.

I'll make PR soon, I just want to check there aren't any other additions to make it more robust.

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

Successfully merging a pull request may close this issue.

4 participants