Custom directional shadow maps#24936
Open
mate-h wants to merge 2 commits into
Open
Conversation
kfc35
approved these changes
Jul 12, 2026
kfc35
left a comment
Contributor
There was a problem hiding this comment.
fyi main has the fix for the ci error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
While I was working on terrain rendering, I realized that I needed to make use of custom shadow maps that raymarches the heightfield towards the light. For the terrain material I use
apply_pbr_lighting. Using this approach, we better support custom shadow maps while still being able to use the pbr lighting code.Use cases:
Solution
pbr_inputnow includes a new field calleddirectional_shadow_factorwhich defaults to1.0Given some function
terrain_shadow_factorthat samples a custom shadow map.Testing
Showcase
Context: the custom shadow map translates to a texture binding in my material, output of a compute pass that ray-marches the terrain heightmap towards the light centered on the camera, where R is the highest occluding elevation and G is ray length. and at fragment shade time the shadow factor value is computed to get cheap penumbras on the terrain.
At first I tried wiring it into the regular cascaded shadow maps but that resulted in quite a bad performance so this is essentially an optimization. This technique based on the Red Dead Redemption 2 Siggraph talk from 2019.
Custom shadow map example:
