No GLTF Morph Target Animation with ShadedMaterial

Hi all, I have an asset pipeline from Blender -> GLTF2.0 -> BablyonJS that seems to me like it should work but I’m running into an issue with morph target animations combined with a ShaderMaterial. The animation works fine with a StandardMaterial but fails with ShaderMaterial. I assume there’s something I need to do in my custom material to properly support the animation.

I have…

  • A mesh I created in Blender and added a Shape Key.
  • Animated that shape key in blender.
  • Exported the mesh and the animation as a .glb (GLTF2.0)
  • Imported that mesh and animation via BABYLON.SceneLoader.LoadAssetContainer()
  • Added the AbstractMesh to the scene via scene.addMesh(mesh, true);
  • Added the AnimationGroup to the scene via scene.addAnimationGroup(animationGroup);
  • Play the animation via;

When I put a StandardMaterial on the mesh, the animation plays. When I put my ShaderMaterial on the mesh, it doesn’t. I’m assuming I’m missing something in the vertex shader. Mine is pretty straight forward, all the exciting bits are the in fragment shader.

precision highp float;

// Attributes
attribute vec3 position;
attribute vec3 normal;
attribute vec2 uv;

// Uniforms
uniform mat4 worldViewProjection;

// Varying
varying vec3 vPosition;
varying vec3 vNormal;
varying vec2 vUV;

void main(void) {
    vec4 outPosition = worldViewProjection * vec4(position, 1.0);
    gl_Position = outPosition;
    vUV = uv;
    vPosition = position;
    vNormal = normal;

Would appreciate it if anyone can push me in the right direction.


This is expected as your shader do not contain the required code to support morph target animation

You may be interested by using a NodeMaterial (very early alpha new feature):

@Deltakosh Cool! The NodeMaterial looks like it could be a great solution. I’ll have to dig into those and see what I can do. My Fragment shader isn’t too complex, I’m just fading out half the mesh that’s facing a direction in world space and doing different effects on the front and back faces of the model.

Is there a reference implementation of a shader that supports Morph Target animations I could look at, or some documentation on the requirements for such a shader?

I was digging through the StandardMaterial and default.vertex.fx but with everything going on in there it is rough trying to find and extract the bits I need.

here is probably a simpler one: