Flickering lighting / shadows on moving Skeletal Meshes

Hey everyone, I’m encountering an issue in 4.26 and 4.27 where skeletal meshes have light / shadow flickering when they move. Below you can see a test setup I made to demonstrate it. It’s just an elongated box mesh attached to the camera in UE4’s first person template. (I added 2 extra copies of the box for demonstration purposes, but that’s not required to encounter the issue)

ShadowArtifacts

It’s most obvious when in shaded areas, where the shadowing flickers in and out. But it can also be seen out in direct lighting, where the issue is reversed - shadows start appearing where they shouldn’t be.

So far I’ve only seen this with baked Stationary lights. This doesn’t happen with Movable lights.

From what I can tell, the issue seems to be related to the physics asset (and/or the resulting bounding box). I can make the issue worse by shrinking the physics asset so that it is smaller than the actual mesh, and I can improve the issue by making the physics asset larger.

Below you can see my phys asset setup. The first picture is what results in the issue shown above. The second picture is how big the phys asset has to be in order to prevent the artifacts from happening.

The phys asset has to be pretty oversized to prevent the flickering, which as far as I know isn’t ideal for a number of reasons (like inaccurate physics, lower shadow resolution, and less accurate culling).

Has anyone else encountered this? Anyone know a fix? Any help would be greatly appreciated!

Ok, I think I’ve found exactly where the issue is coming from, but I still don’t have a very good solution. I’m pretty sure the issue is the pre-shadow frustum.

It appears that the size, shape, and location of the pre-shadow frustum only update when the object has moved a far enough distance. The problem is, this means the object can actually move outside of the pre-shadow frustum before the frustum updates, and when this happens, shading is wrong on parts of the mesh outside of the frustum. The flickering happens because parts of the mesh are constantly coming in and out of the frustum as the mesh moves.

This can be visualized by entering the following two console commands:
show ShadowFrustums
r.Shadow.DrawPreshadowFrustums 1

PreshadowFrustum

The reason it’s tied to the physics asset (as far as I can tell) is because the size of the physics asset determines the size of the object’s bounding box. The size of the bounding box then determines the size of the object’s pre-shadow frustum.

So… by making the bounding box significantly larger than the actual object, you can get a pre-shadow frustum that’s big enough to contain the object even while it moves.

This works, but I’m hoping there’s a solution that isn’t just making the bounding boxes oversized. If anyone has any thoughts or ideas, please let me know!