I currently have a requirement to implement deformation between a planar surface and a spherical geometry using the MorphTargetManager. While the implementation works correctly with StandardMaterial, I would like to utilize ShaderMaterial for enhanced visual effects and customization. However, the relevant documentation does not provide guidance on how to implement ShaderMaterial in this context.
Is it possible for MorphTargetManager to work with ShaderMaterial?
NodeMaterial and PBR materials are not well-suited to my specific use case.
Hello @superTigery,
Yes, MorphTargetManager can be used with ShaderMaterial, but you’ll need to manually handle the morph target logic in your shader code. This includes setting up the required attributes (position, normal, etc.), blending between targets using the morph influence uniforms, and ensuring the geometry has morph targets enabled. Unlike StandardMaterial, ShaderMaterial won’t manage this automatically—so you control the deformation behavior entirely through GLSL. This gives you the customization you need, but requires shader-level setup.
Are you saying that I need to pass the positions of two geometries, the normals of two geometries, and the influence as well? Could you please help me provide a minimal demo that runs on my PG? Thank you very much.
No clue how “Thomas Henry” slipped through our bot detection filters. Its response wasn’t half-bad, which is shocking!
Have you considered using a Material Plugin? It lets you inject your own shader code
into different parts of the StandardMaterial or PBRMaterial mega shaders. This way, you can avoid the complexity of writing a full shader from scratch (like with ShaderMaterial), especially when dealing with features like morph targets.
Here is the PG with only the vertex shader part modified.
Adding morph target support to ShaderMaterial is as simple as this.
since this kind of work requires a lot of context that is not covered in the documentation, I personally recommend cloning the Babylon.js source code and checking the implementation of the necessary features.