Getting shadows to update with clip planes

Welcome aboard!

I did not find a simple way to do it…

A somewhat complicated way to do it:

  • use the shadowGenerator.onBeforeShadowMapRenderMeshObservable observable to know which mesh is about to be rendered in the shadow map
  • use the shadowGenerator.onBeforeShadowMapRenderObservable observable to bind the clip planes to the effect of the mesh that is about to be rendered if it is the sphere
  • you need to override shadowGenerator._isReadyCustomDefines to set the clip planes on the scene if the mesh which is about to be rendered is the sphere

Here’s the PG:

For demonstration purpose I have added a cube which is not impacted by the clip planes.

5 Likes