BUG? Offscreen objects cost MORE than on on-screen objects when casting shadows?

Watch the GIF, it’s pretty self-explanatory albeit strange issue.
UE5.1_ShadowCulling_Issue2

  • I have 4000 cubes layered on top of each other casting shadows.
  • When they’re ONSCREEN, the performance is normal.
  • But moving them OFFSCREEN (something you would expect to improve performance) makes performance significantly worse.

It doesn’t matter if the objects are Nanite or not, the performance issue with moving shadow-casting objects OFFSCREEN is the same.

This was done in a blank UE5.1 project, but we first encountered this in our main project after moving to 5.1.

EDIT: I forgot to mention, but the result is the same with Occlusion Culling disabled as well.

UE 5.1
Tried to recreate it and seeing a boost in frames with occlusion culling off.
With cubes ~43 fps
No cubes over 70 fps

Which shadow technology are you using? Virtual Shadow Maps or the older cascade shadows?

My previous one was using VSM, which was what I believe it defaulted to. I just tried again with standard cascade shadow maps and the result was the same (recording eats some perf but it’s the same effect). Disabled occlusion culling for this one as well and it didn’t fix anything.
UE5.1_CascadeShadows

Also for anyone else trying this, attached is a text file of the entire scene. You can create a blank map and copy the text and paste it straight into the map to recreate exactly what I have. It’s just:

  • A single directional light (settings unchanged)
  • The default ‘Floor’ object
  • 4000 cubes from the Engine Basic Shapes meshes
    4000Cubes_VSM_Shadows_Issue.txt (5.7 MB)

For context, this all came up another guy on our team had a level blocked out using the Blockout Tools plugin content and performance tanked when switching to 5.1. It was tied to shadows and where the camera was looking, although in unexpected ways (like really poor performance when looking at the empty horizon).

1 Like

I had the directional light set to default settings of a new blank “simple” scene. Distance Field Shadows are off.

Does this occur when the cubes are not stacked? As in, is this actually a practical problem? Regardless, definitely seems like something you should report as a bug

Try “r.LumenScene.DirectLighting.OffscreenShadowing.TraceMeshSDFs=0”. It’s hard to make a render pipeline that can handle anything you throw at it in what ever form you like. A feature becomes a bug so easily.

2 Likes

Since this thread has popped up again, I wonder if the reason this was happening was because of the efficiency of screen tracing. When the mesh is off screen, it has to resort to ray tracing, and tracing 4000 objects is a bit expensive. When it’s on screen, it can skip raytracing and rely on the screen traces which are pixel bound, not instance bound.
You can validate this by disabling screen traces to see if the performance is more uniform.

2 Likes