Implement percentage-closer filtering (PCF) for point lights.#12910
Conversation
I ported the two existing PCF techniques to the cubemap domain as best I could. Generally, the technique is to create a 2D orthonormal basis using Gram-Schmidt normalization, then apply the technique over that basis. The results look fine, though the shadow bias often needs adjusting. For comparison, Unity uses a 4-tap pattern for PCF on point lights of (1, 1, 1), (-1, -1, 1), (-1, 1, -1), (1, -1, -1). I tried this but didn't like the look, so I went with the design above, which ports the 2D techniques to the 3D domain. There's surprisingly little material on point light PCF. I've gone through every example using point lights and verified that the shadow maps look fine, adjusting biases as necessary.
|
Please don’t merge this until I have reviewed it. It’s something I particularly care about. |
|
I looked at three.js. It uses a 3x3 box filter: https://github.com/mrdoob/three.js/blob/6421f3a49ebed3d07de781776f47624e6d26e896/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js#L295-L309 I also looked at Blender. It doesn't seem to have any PCF for point lights at all. |
IceSentry
left a comment
There was a problem hiding this comment.
Tested on windows 10, webgl and webgpu. Everything looks good. Code quality is great. I like changing the names to Gaussian and Temporal. I don't understand the math enough to comment on it though.
|
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1298 if you'd like to help out. |


I ported the two existing PCF techniques to the cubemap domain as best I could. Generally, the technique is to create a 2D orthonormal basis using Gram-Schmidt normalization, then apply the technique over that basis. The results look fine, though the shadow bias often needs adjusting.
For comparison, Unity uses a 4-tap pattern for PCF on point lights of (1, 1, 1), (-1, -1, 1), (-1, 1, -1), (1, -1, -1). I tried this but didn't like the look, so I went with the design above, which ports the 2D techniques to the 3D domain. There's surprisingly little material on point light PCF.
I've gone through every example using point lights and verified that the shadow maps look fine, adjusting biases as necessary.
Fixes #3628.
Changelog
Added
Changed
ShadowFilteringMethod::Castano13andShadowFilteringMethod::Jimenez14have been renamed toShadowFilteringMethod::GaussianandShadowFilteringMethod::Temporalrespectively.Migration Guide
ShadowFilteringMethod::Castano13andShadowFilteringMethod::Jimenez14have been renamed toShadowFilteringMethod::GaussianandShadowFilteringMethod::Temporalrespectively.