setShadowCaster(True, new_res, new_res) on an existing light can break shadow cameras for other lights (the shadow cameras get stuck and stop updating)

Bug #1672560 reported by ellie
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Panda3D
Fix Released
Undecided
rdb

Bug Description

Calling setShadowCaster(True, new_res, new_res) on an existing shadow-casting light with a new, different shadow resolution can sometimes break the shadow cameras for OTHER existing lights (of which the shadow cameras get stuck and stop updating).

This happens 100% for me in my game which is a bit of a showstopper, so a fix would be nice.

To reproduce:
1. Get panda 1.10 git master in some recent version (I didn't test 1.9.3 yet)
2. Get the "shadows" example
3. Copy the attached basic_modified.py over the existing basic.py of the shadows example and run it and wait (no interaction necessary)

This is how it looks like with the bug happening: https://www.homeofjones.net/temp/shadowbug.webm

Expected behavior: teapot shadow always updates correctly

Actual behavior: teapot shadow sometimes "gets stuck" and weirdly falls down along with camera (see the video)

PS: SORRY that the test code is so extremely weird. I tried making it more minimal but that would always stop the error from occuring. Sadly I couldn't figure out how to get it to happen with more simple code

Revision history for this message
ellie (et1234567) wrote :
description: updated
Revision history for this message
ellie (et1234567) wrote :

Just a small update: I'm not sure anymore the setShadowCaster(True, new_res, new_res) with a shadowmap resize actually triggers this or turning off a light's shadows entirely and re-enabling does, or something else... anyway, the attached reproducing example somehow triggers it and so does my current game project.

Revision history for this message
ellie (et1234567) wrote :

Another small update: I observed a few additional things:

1. In a complex project with many shadows where this bug occurs, FilterManager unexplicably breaks for me

I have observed that in a trivial unmodified shadows basic.py example, I can easily add the FilterManager/CommonFilters and the glow shader and it works. However, in my game (where the bug described in this ticket with the sudden weird shadow camera freezes occurs consistently) adding the FilterManager will lead to the camera image freezing as soon as the FilterManager is activated, or alternatively a black screen is shown, or even sometimes something that looks like uninitialized memory - but only when I actually enable the Filtermanager. The game is still responsive when that happens, so this seems to be purely some sort of render problem.

2. With many lights there are sometimes odd shadow map artifacts

When I add a lot of spot lights, not only does the bug described here occur more often but there also seems to be a higher chance of random shadow artifacts - but only with specific light placements. I had a point light + spot lights up to the limit before (with significant lower FPS and more GPU load) with no blinking and flickering of spot lights, but when I use 3 spotlights and a few non-shadowed lights with significantly better render times I sometimes see artifacts. Also, setShadowCaster(True, new_res, new_res) will always cause a short glitch on an existing light that looks like a very short 1-2 frames of something uninitialized memory-looking

3. Others have managed to reproduced this bug on IRC

Two others have reproduced the bug with the reproduction code attached above. This makes me think the additional glitches I just described are possibly related, and not simply e.g. my GPU dying. (I have also played through the new Tomb Raider reboot linux port recently on this GPU with no issues)

TL;DR / Conclusion: 1. I still don't know what the cause is and I couldn't find fewer lines of code that reliably reproduce it, but 2. I think it might be some sort of corruption bug which affects more than just shadow cameras freezing as in the initial bug description, but it might also possibly be breaking FilterManager for me. It seems to occur more likely when being close to the forward renderer's light limit and removing/readding and shadowmap-resizing lights a lot.

Revision history for this message
ellie (et1234567) wrote :

Clarification: setShadowCaster(True, new_res, new_res) will 99% cause a very short glitch which at least is a short blink/flicker of the resized light, but sometimes it looks like some actual blocky pattern of something uninitialized memory-looking is seen in the shadow for like 1-2 frames. I don't know how related that is though

Revision history for this message
rdb (rdb) wrote :

Thanks so much! Some shadow buffers could indeed enter a "zombie" state after a different shadow buffer on the same scene is removed. A fix has been made:
https://github.com/panda3d/panda3d/commit/fa1b656961feb0b0323ea46898eed7c450178813

Changed in panda3d:
assignee: nobody → rdb (rdb)
milestone: none → 1.10.0
status: New → Fix Committed
Revision history for this message
ellie (et1234567) wrote :

I tested the fix both on the minimal example and my game and it works <3 Thanks!

rdb (rdb)
Changed in panda3d:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.