Enable Animations Blending for VAT

Hey! It would be cool to have such feature.

There is a main question: Does it possible to mix 2 animations in shader? @Evgeni_Popov I know you are know a lot about VAT :grinning:

I think event such simple case(blend 2 animations) can help a lot to get better visual in the apps.

My assumption:

We need:

  1. 1 buffer(animation settings) for each animations using in blending
  2. 1 buffer for blending settings
  3. additional 4 texture’s reads per each bone
  4. blending logic(IDK how to properly mix matrices…) Does Matrix.Lerp work for animation blending? Babylon.js/packages/dev/core/src/Shaders/ShadersInclude/bakedVertexAnimation.fx at acf3f57f05cb06322ee1ee08bf6a63d30985ae24 · BabylonJS/Babylon.js · GitHub Like
mat4 finalVATInfluence = lerp(VATInfluence, VATInfluenceSECOND, blendFactor);
1 Like

I have a try with this(2 bones per vertex):

  mat4 VATInfluence2;
  VATInfluence2 = readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture, matricesIndices[0], VATFrameNum) * matricesWeights[0];
  VATInfluence2 += readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture, matricesIndices[1], VATFrameNum) * matricesWeights[1];
  float mixfactor = (sin(time) + 1.0)/2.0;
  mat4 VATMixing = (VATInfluence * (1.0 - mixfactor)) + (VATInfluence2 * mixfactor);

  finalWorld = finalWorld*VATMixing;

And it works!


The problem would be to make something generic / versatile enough to be useful. In theory, anything is possible, but in practice, it’s more difficult :slight_smile:

We might have to port a subset of the animation system to the GPU (which is not in the pipeline at the time).