Dynamic shadows with VSMShadowMap

I am trying to dynamically adjust the rendering quality to ensure a smooth performance for the users and one of the elements of this tuning is shadow map size. After a significant amount of struggles I found out that VSMShadowMap is not a good candidate for this as shown here:

Could you please suggest if it is possible to make VSMShadowMap work in the dynamic setup where the light position, post-processing and the shadow-map resolution changes on the fly or it is better to use PCF shadows with lower resolution maps? Thanks!

Fun note - opening your codepen on iPhone 12 crashes and restarts the entire phone :smiling_face_with_tear:

In terms of performance - yes, PCF for dynamic objects combined with baked lightmaps for static objects should be cheaper.

Oh wow :slight_smile: I found a way to break iPhone :slight_smile: I assume it is because of frequent changes and high resolution paired with the high sample levels.

I usually have only one object in the scene with no static shadows. But, just curious, is it an expected behavior for the VSMShadowMap?

PS: PCF shadows work fine. You can try uncommenting the line in the example above to see the difference.