Overlapping contact hardening shadows rendering issue

While testing out the different shadow types, I stumbled across some weird rendering issues with the contact hardening shadows. When two shadows are overlapping with useContactHardeningShadow set to true, the shadow casted by the object further away from the light source gets affected by shadows closer to the light source. To demonstrate this effect, I slightly modified the PCSS Shadow Example from the documentation. https://playground.babylonjs.com/#B48X7G#41
This also occurs if the boxes are receiving shadows.

Welcome aboard!

That’s a limitation of the method. The shadow intensity depends on the distance from the shadowed pixel to the occluder. As only a single occluder is registered in the shadow map (the nearest to the light source), the intensity of the shadow can be wrong when multiple shadows overlap, as in your example. To make it work, we would need to keep all the occluder distances and pick the one nearest to the shadowed pixel to compute the shadow intensity, but it’s too much involved (the base technic is already quite resource and performance consuming).

Thank you for the response. I didn’t know that this can’t be fixed with the current implementation. I might have to choose a different method to render overlapping shadows in this case.

All other filtering methods will work, it’s only a specificity of PCSS because the intensity depends on the depth stored in the shadow map.