# Backed texture : limit?

**URL:** <https://forum.babylonjs.com/t/backed-texture-limit/45132>\
**Category:** Questions\
**Created:** [October 23, 2023, 8:27pm UTC](https://forum.babylonjs.com/t/backed-texture-limit/45132 "2023-10-23T20:27:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![glad](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@glad](https://forum.babylonjs.com/u/glad)\
**Post date:** [October 23, 2023, 8:27pm UTC](https://forum.babylonjs.com/t/backed-texture-limit/45132/1 "2023-10-23T20:27:50Z")

</div>

Hi,

Maybe I didn’t get something about [baked textures](https://doc.babylonjs.com/features/featuresDeepDive/animation/baked_texture_animations#serializing-and-loading-vats)

The vertexData.json tells the width is 264.  
I don’t understand why my baked texture only has a width of 264, when my mesh has 15k vertices.  
it has a height of 32, which is correct because the anim has a length of 32 frames.

I reused the code in the example.

```auto
let baker = null,
mesh = null;

const ranges = [{ from: 0, to: 32, name: "My animation" }];
SceneLoader.ImportMeshAsync("", "/path/", "untitled.glb", scene, undefined)
.then((importResult) => {
        mesh = importResult.meshes[1]; //<- offset 1 because 0 has no skeleton

        // create the baker helper, so we can generate the texture
        baker = new VertexAnimationBaker(scene, mesh);
        // you can slice the animation here with several animation ranges.
        return baker.bakeVertexData(ranges);
})
.then((vertexData) => {
        // we got the vertex data. let's serialize it:
        const vertexDataJSON = baker.serializeBakedVertexDataToJSON(vertexData);
        // and save it to a local JSON file
        let a = document.createElement("a");
        a.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(vertexDataJSON));
        a.setAttribute("download", "vertexData.json");
        a.click();
      
});

```

So, I thought I should have a texture width of about 15k.  
total size of the texture 15k \* 3 (\<=\>3 points in vertex) \* sizeof(float) \* 32 lines

Not sure what I missed…

May you help? 🙃 🙂

---

<div class="post-metadata">

**Author:** ![glad](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@glad](https://forum.babylonjs.com/u/glad)\
**Post date:** [October 23, 2023, 8:58pm UTC](https://forum.babylonjs.com/t/backed-texture-limit/45132/2 "2023-10-23T20:58:16Z")

</div>

Hmm  
Reading [this post](https://forum.babylonjs.com/t/backedvertex-animation-from-external-source/36345/4) it is not per vertex but a matrix per bone.

Quick question before I deal with it tomorrow: is each matrix local to the bone? So the value has to be considered relative to the root of the mesh and then, one can apply the translation as needed?  
3x3 or 4x4 matrices?  
The base of those matrices is the gltf’s bind pose of each bone?

---

<div class="post-metadata">

**Author:** ![docEdub](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/docedub/32/14525_2.png) [@docEdub](https://forum.babylonjs.com/u/docEdub)\
**Post date:** [October 23, 2023, 11:07pm UTC](https://forum.babylonjs.com/t/backed-texture-limit/45132/3 "2023-10-23T23:07:15Z")

</div>

cc @Evgeni_Popov

---

<div class="post-metadata">

**Author:** ![Raggar](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raggar/32/20672_2.png) [@Raggar](https://forum.babylonjs.com/u/Raggar)\
**Post date:** [October 23, 2023, 11:25pm UTC](https://forum.babylonjs.com/t/backed-texture-limit/45132/4 "2023-10-23T23:25:34Z")

</div>

The baked matrices are the final matrices after all transformations have been done

---

<div class="post-metadata">

**Author:** ![glad](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@glad](https://forum.babylonjs.com/u/glad)\
**Post date:** [October 24, 2023, 5:19am UTC](https://forum.babylonjs.com/t/backed-texture-limit/45132/5 "2023-10-24T05:19:27Z")

</div>

Thanks,

for the size of it,  
`mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));`,

so a 4x4 matrix.

@Raggar : I currently roam in the code, but it should be the final transform of the local matrix? in comparison to the bind pose?

some food:

```auto
_computeTransformMatrices(targetMatrix, initialSkinMatrix) {
    this.onBeforeComputeObservable.notifyObservers(this);
    for (let index = 0; index < this.bones.length; index++) {
      const bone = this.bones[index];
      bone._childUpdateId++;
      const parentBone = bone.getParent();
      if (parentBone) {
        bone.getLocalMatrix().multiplyToRef(parentBone.getFinalMatrix(), bone.getFinalMatrix());
      } else {
        if (initialSkinMatrix) {
          bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getFinalMatrix());
        } else {
          bone.getFinalMatrix().copyFrom(bone.getLocalMatrix());
        }
      }
      if (bone._index !== -1) {
        const mappedIndex = bone._index === null ? index : bone._index;
        bone.getAbsoluteInverseBindMatrix().multiplyToArray(bone.getFinalMatrix(), targetMatrix, mappedIndex * 16);
      }
    }
    this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  }

```

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [October 24, 2023, 9:38am UTC](https://forum.babylonjs.com/t/backed-texture-limit/45132/6 "2023-10-24T09:38:22Z")

</div>

Yes, it is the final transformation of the local bone matrix, as `bone.getLocalMatrix().multiplyToRef(parentBone.getFinalMatrix(), bone.getFinalMatrix());` shows.

Note that because it is skinning, we also remove the bind pose by multiplying by the inverse bind matrix (`bone.getAbsoluteInverseBindMatrix().multiplyToArray(bone.getFinalMatrix(), targetMatrix, mappedIndex * 16);`).

---

<div class="post-metadata">

**Author:** ![glad](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@glad](https://forum.babylonjs.com/u/glad)\
**Post date:** [October 24, 2023, 11:04am UTC](https://forum.babylonjs.com/t/backed-texture-limit/45132/7 "2023-10-24T11:04:14Z")

</div>

Thanks! Let’s get to work now 👍
