godot
godot copied to clipboard
Shadow fade for omni lights actually stops the shadow from updating while faded out to improve performance.
This is to address https://github.com/godotengine/godot/issues/88085
- Bugsquad edit, fixes: https://github.com/godotengine/godot/issues/88085
EDIT: Actually, apologies, this works before I thought it did in the pipeline, didn't read properly, so is likely a good approach.
Yes, this looks good. I am also wondering whether the shadows should ever be culled out before the lights. If all the shadow casters will be rendered when light is showing, or none of the shadow casters, this PR should cover all bases. If we want shadows to be able to fade during the light, then it becomes much more tricky to deal with.
I had a little go at this this morning with #89740, although I'm now realizing it is a bag of worms, because for lights facing the viewer, we sometimes have to render casters outside the shadow range, so I've shelved that for now.
UPDATE: Looking through this looks good to me, I will test a bit more later if I get a chance, but probably needs a look through from a 4.x rendering team, as I'm not so familiar with 4.x (although a lot is similar there are some changes from 3.x).
You can fade the shadows before the lights. There are 3 parameters on the light for the fade start (of the light), the fade start of the shadow, and the distance of the fade (shared between the 2). I've been using this by fading the shadows out at a shorter distance than the lights, so that aspect seems to work.
Hopefully not rendering the entire shadow map as done here will mean we won't have to deal with the caching issues which are quite tricky (the shadowmap should just remain dirty, and keep trying to render until it comes within range).
Once the nitpicks above are done this looks fine to me (the function should take a light RID
if possible imo). I've tested (reasonably, hard to test every permutation) and it seems to work fine.
Probably one of the 4.x rendering team should also review when back from GDC prior to moving forward.
Updated the code. Hopefully I got everything!
Thanks!