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.


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:


Ah, that makes sense! Thanks!