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

OmniLight3D Shadows behave erratically when the 33rd light is added to the scene. #92220

Open
jamie-pate opened this issue May 21, 2024 · 3 comments

Comments

@jamie-pate
Copy link
Contributor

jamie-pate commented May 21, 2024

Tested versions

Reproducible in Godot v4.3.dev6 and 4.2.2-stable

System information

Godot v4.3.dev6 - Ubuntu 22.04.4 LTS 22.04 - X11 - Vulkan (Forward+) - integrated Intel(R) Graphics (ADL GT2) () - 12th Gen Intel(R) Core(TM) i7-12700H (14 Threads)

Issue description

When creating 33 OmniLight3D objects with shadows that are visible at the same time the nearest lights to the camera are sometimes broken.. I would expect that shadows would be allocated based on camera distance but they seem to get 'stuck'....

I would expect the following behavior:

  1. Lights closer to the camera should have priority in the texture atlas so they never go dark
  2. Using distance fade should reallocate the texture atlas when light shadows fade out, it doesn't seem to do this

WORKAROUND:
Adding more texture slots in the shadow atlas avoids this issue by creating enough shadow maps for all the lights.

Steps to reproduce

Load the reproduction project and run it. Notice that some lights are 'off'

Recreating all the lights seems to correct the issue, but that sounds expensive...
image
ezgif-3-7370b444aa

Minimal reproduction project (MRP)

many-lights-shadows-broken.zip

@clayjohn
Copy link
Member

This may be partially fixed in Beta 1 as there was a problem where regions could over-allocate and then lights would get stuck (#91545). #89729 may also help.

Ultimately, we need to overhaul the shadow quadrant selection process. Right now it gives priority to closer lights, but its still possible for lights to get stuck and not update when they should. Basically, right now lights try to grab an appropriate quadrant given their size and distance from the camera. When there is heavy contention for quadrants, this can lead to certain lights not getting a good spot.

We need to ensure that the closest lights always get a spot on the atlas and that lights jump quadrants as little as possible

@clayjohn
Copy link
Member

Testing the MRP locally I can reproduce some issues with dev6 (not to the extent that you show in your post though). All the issues I can reproduce are fixed in latest master though. In master, all lights appear on the mesh just fine and there is no flickering

@mrjustaguy
Copy link
Contributor

from my testing I've found that it just keeps lights allocated in the same quadrant as long as they aren't culled, even if they're no longer the closest and should be getting a lower quality quadrant if any

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

4 participants