Shadow Frustum Queries not culling out shadows

Hi,

What is the best way to leverage the results of the shadow frustum queries to cull out hidden shadows?

In my test scene, queries are issued for my shadow casting point/spot lights with a EShadowDepthCacheMode of

Mods, please move if this isn’t the correct sub-forum.

I’ve attached some images to better show my issue:

This one shows my scene. The point light I’m trying to occlude is selected in the editor. The transform widget shows it’s location. The red circle highlights the platform/wall I’ll stand on that should block the light from my view.

Here is my renderdoc profile:

  • “View for this frame” shows my current view which is completely blocked by a wall.
  • “Occlusion Query for point light” shows the Shadow Frustum Query for my point light.
  • “ShadowDepth draw for point light” shows where the shadow map is generated for this light
  • “Light pass for point light” shows the shadow projection for the light.

If I’m understanding things correctly, I’d expect the Shadow Frustum Query to return zero pixels which should result in the shadow map not being generated or projected.

Is my understanding correct?

This is pretty interesting indeed. [MENTION=24522]John Alcatraz[/MENTION]
Light sphere of that size should return zero for shadow frustum query.

Any update on this?

I just saw this thread. Thanks for sharing your findings.

I investigated and found a few problems, all caused by the whole scene shadowmap caching. CacheMode was not being set correctly when looking up the query as you noticed. However, even after fixing that, the SDCM_StaticPrimitivesOnly shadowmap still gets rendered when it should have been occluded. This is because SDCM_StaticPrimitivesOnly shadowmaps are only rendered for one frame (in the case of movable light not moving), but occlusion queries must be fetched a frame later than they are issued. To fix this I just check the SDCM_MovablePrimitivesOnly query for SDCM_StaticPrimitivesOnly shadowmaps. This optimization needs some more testing and then I will check it in. This will be in 4.18 if nothing goes wrong.

Excellent. I’ll keep an eye out for your fix.

Thanks!

The fix made it into 4.17 just in time:

cl 3546615
[Copy] Fixed shadow occlusion culling broken by shadowmap caching change. FProjectedShadowKey is now computed correctly for whole scene shadows and SDCM_StaticPrimitivesOnly shadowmaps will fall back to the query for a SDCM_MovablePrimitivesOnly, since the static primitives shadowmap’s query is not issued every frame.

Thanks again for catching this

Thanks so much for looking into this!

THIS, is how you do a bug report. Great find Benny and thanks for fixing !

Since when is this shadow caching a thing? It’s always rendering all 4 shadow cascades every frame for me in 4.16.

Maybe I’ve misread your post.