VSM - Corrupted shadows around the Dynamic Shadow Distance range

Hey, I’m reporting an issue with corrupted shadows cast by VSMs even in simple test cases. See attached clips and screens.

I believe that the shadows behave incorrectly around the distance of “Dynamic Shadow Distance”. I believe they should disappear by measuring the actual camera distance to the given shadow place, irrelevant of where the object is. There should be no left overs from some part of the mesh casting shadows even beyond this distance. I believe the issue to be partially caused by the VSM cache system.

This partially happens, with the lower part of the shadow from the screens / clips I provide. The upper part seems like remains there due to not touching that single VSM page, maybe not invalidating it. But it does not happen correctly.

The clips show 2 different ways this can break, with the same setup. I have a feeling this is timing dependent but it’s not so trivial to get the repro for full shadow pop-in. That’s rarer. Usually what happens during zoom-in is the reverse of zoom-out, so broken both ways similarly.

This is default setup, untouched VSM clipmap ranges, no distance field shadowing, no contact shadows.

Please let me know if I can work around the issue or where could I fix it.

[Attachment Removed]

Steps to Reproduce

Clean engine

  1. Open the template open world map
  2. Place engine cube, scale it up to 20,20,20 so the shadow is clearly visible at a bigger distance
  3. Zoom out a little bit
  4. Notice how the shadow looks (screen attached, named Step4)
  5. Zoom out further, to the distance of 20000, which is the default dynamic shadow distance
  6. Notice how the shadow looks - part is visible, part is gone (screen Step6)
  7. Zoom out further, notice that the lower part goes missing, but the one closer to base keeps shadowing, despite the fact that it is far outside the range given (screen Step7)
  8. Zoom out even more, until the remaining of the shadow is gone (screen Step8). Notice that the range is way higher than 20000 from the camera
  9. Start zooming in. Sometimes what happens is instant pop of shadow to the state from previous screen, from point 8, where just the base shows up. Also corrupted state.
  10. When going all the way to zoom in, we have reverse of the previous.

Expected behavior: the shadow gets culled with the distance from camera, not by sudden pops and cuts in weird spots.

Note: Most of the issue does not occur with “r.Shadow.Virtual.Cache 0”. There are no half-corrupt states, the shadow is culled with distance correcly albeit in an ugly way - it is an instant pop in-out, no fade based on actual shadow distance, but seems like checks just the object location. While technically correct, not acceptable quality-wise for a shippable game.

[Attachment Removed]

Hello,

Thank you for reaching out.

I’ve been assigned this ticket, and we will be investigating this VSM shadow artifacts for you.

[Attachment Removed]

Hello,

Thank you for reporting this. I can confirm this behavior can be reproduced as described in the latest CL, and have opened a bug report:

https://issues.unrealengine.com/issue/UE\-366232

The tracker will be visible after it is approved internally at Epic Games and is publicly accessible.

If you have any further questions, please let us know.

[Attachment Removed]