Skip to content

shadow: introduce a tighter caster culling method#10021

Open
show50726 wants to merge 7 commits into
google:mainfrom
show50726:dev/caster-culling
Open

shadow: introduce a tighter caster culling method#10021
show50726 wants to merge 7 commits into
google:mainfrom
show50726:dev/caster-culling

Conversation

@show50726

Copy link
Copy Markdown
Contributor

Inspired by this post:
https://x.com/SebAaltonen/status/1717455941551919261?s=20

The basic idea is to look at the view frustum from the light, and find those planes that construct a "silhouette". All the renderables outside this silhouette will never cast the shadow to the view frustum so we can safely cull them. Note that in our approach, we construct a table to easily look up for each back planes combination, what would be the silhouette vertices, so we can avoid some calculation.

The basic idea is to look at the view frustum from the light's perspective and find the planes that construct a "silhouette". Any renderables outside this silhouette will never cast a shadow into the view frustum, so we can safely cull them. Note that in our approach, we construct a lookup table for each combination of back-facing planes to determine the silhouette vertices, allowing us to avoid some calculations.

Implementation reference:
https://github.com/godotengine/godot/pull/82584/changes#diff-8babe54c0b184d1c71d515dc1a35aedcb772169ef06ade4fe5d7f162086aaa2a

Comparison

I tested it with gltf_viewer using the Bistro scene.

Without tighter caster culling:
6pWPGo6fuwo5XhE

With tighter caster culling:
6eCd6k5W544hEVw

We can observe that the frame time is slightly lower in the image below.

@show50726
show50726 requested a review from pixelflinger May 19, 2026 07:27
@show50726 show50726 added the internal Issue/PR does not affect clients label May 19, 2026
Comment thread filament/src/ShadowMapManager.cpp Outdated
Comment thread filament/src/ShadowMapManager.cpp Outdated
Comment thread filament/src/ShadowMapManager.cpp Outdated
Comment thread filament/include/filament/Engine.h Outdated
Comment on lines +464 to +469

/**
* Enable tighter caster culling for shadow maps.
* This can improve performance by culling shadow casters more aggressively.
*/
bool tighterCasterCulling = false;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to not always do this?
I mean, should this be a config like you did, or just a feature_flag, that we eventually remove?

What are the downsides of always doing this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think people might want to leave this feature disabled when they are at CPU bound instead of GPU bound.

Additionally, as discussed offline, this shouldn't be used alongside techniques like VSM or mipmapping. Rather than disabling culling automatically, I added a warning in the configuration so the user can decide.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made it a per-view option instead

Comment thread filament/include/filament/Engine.h Outdated
Comment thread filament/src/details/Engine.cpp Outdated
Comment thread filament/include/filament/View.h
@show50726
show50726 force-pushed the dev/caster-culling branch from 12f9249 to ac2d79f Compare June 6, 2026 04:35
show50726 added 2 commits June 6, 2026 12:36
address comments

push frustum planes 1 texel away

add warnings

make tigher culling a per-view config
@show50726
show50726 force-pushed the dev/caster-culling branch from ac2d79f to 851b219 Compare June 6, 2026 04:36
@show50726
show50726 requested a review from pixelflinger June 6, 2026 04:41
@show50726
show50726 force-pushed the dev/caster-culling branch 2 times, most recently from 2f1103f to 58284b5 Compare June 8, 2026 05:07
@show50726
show50726 force-pushed the dev/caster-culling branch from 58284b5 to 120768a Compare June 8, 2026 05:41
Comment thread web/filament-js/jsbindings.cpp Outdated
@show50726
show50726 requested a review from pixelflinger June 25, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Issue/PR does not affect clients

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants