Vertex Animation Texture with shadows?

Hi guys,

I might have a tough one - recently got to use the Vertex Baked Textures (docs here: Baked Texture Animations | Babylon.js Documentation) and wanted to see whether is possible to apply shadows to the instances.

As you can see in the playground, the shadows are static, even when the animation plays.

Is there a way we could sample the AnimationManager & update the Shadow texture accordingly, or the effort would be too much?

You can do it by using ShadowDepthWrapper: https://playground.babylonjs.com/#CP2RN9#56

I added this line in your PG:

mesh.material.shadowDepthWrapper = 
     new BABYLON.ShadowDepthWrapper(mesh.material, scene);

This is a very basic implementation that uses the shader code of mesh material for shadow. There is too much overhead and reduce the number of instances you can render. You might want to come up with a custom ShaderMaterial implementation. See documentation: Shadows | Babylon.js Documentation

6 Likes