Need help with shadow for CustomMaterial

I have a CustomMaterial that modifies the vertex positions, and I’m trying to use ShadowDepthWrapper to correct the shadow, but it is not working.

Playground: https://www.babylonjs-playground.com/#UXCB15#153

Could someone help me figure out what I’m missing? Thanks!

has a section on this.

You should not save the effect as you do in material.onBindObservable because this event is raised several times, when rendering into the shadow (cascade) map(s) and when rendering the regular object.

Also, you should update time somewhere else than in material.onBindObservable because this method is called several times in a frame.

Here’s a fixed PG:

4 Likes

Ah, that makes sense! Thanks!