How to get this simple contact hardening shadow done right?

I was playing with shadows in BabylonJS and trying to get this simple contact hardening shadow done right, currently it’s generating a weired shadow as you can see here: I found it helps if I reduce contactHardeningLightSizeUVRatio but then it is no longer realistic, what other settings need to be fine-tuned?. Thanks!

By tweaking a little bit the min/max shadow Z planes and, most importantly, the spot angle (30° instead of 90°), I could get this:

This definitely looks better however I do want the spotlight angle to be wider or contactHardeningLightSizeUVRatio to be larger to make the shadow more subtle, but whenever I do either the shadow artifact comes back again. Is there any way to do this without having to decrease the angle? Also is there a general guideline on how to set the values for the angle, UVRatio, shadowMinZ and shadowMaxZ for best results? Thank you!

We have Shadows | Babylon.js Documentation for general advices about shadows, but nothing specific to spot lights.

The problem is that the spot is a bit far from the surface, and the projection of the torus in the shadow map is small because of the large angle:

Shadowmap when angle=90°:

Shadowmap when angle=30°:

I don’t really see a way to fix it, except by using smaller angles and/or making the torus bigger…

Got it, I will play more with these settings, thank you very much!

Hi I do have a follow up question on this regarding ShadowOnlyMaterial in case you have any insight: Abrupt change in shadow effects when using ShadowOnlyMaterial Thanks again!