# Optimizing VAT Baking to near-instant and using Float16 for 50% memory savings

**URL:** <https://forum.babylonjs.com/t/optimizing-vat-baking-to-near-instant-and-using-float16-for-50-memory-savings/58940>\
**Category:** Demos and projects\
**Created:** [June 12, 2025, 3:59am UTC](https://forum.babylonjs.com/t/optimizing-vat-baking-to-near-instant-and-using-float16-for-50-memory-savings/58940 "2025-06-12T03:59:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![knervous](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knervous/32/46952_2.png) [@knervous](https://forum.babylonjs.com/u/knervous)\
**Post date:** [June 12, 2025, 3:59am UTC](https://forum.babylonjs.com/t/optimizing-vat-baking-to-near-instant-and-using-float16-for-50-memory-savings/58940/1 "2025-06-12T03:59:36Z")

</div>

Hi all, I’m working on optimizing all parts of my game currently and the next up was VAT Textures. While I am pre-baking the VAT and pulling in through http in runtime, the time it took to bake VAT was something that stuck out as ripe for optimization

**Part 1: Speed (many orders of magnitude increase)**

Final numbers from current vat baking to this implementation: _~1.5 minutes to 300ms_  
Output from the playground: _Took 297.89999997615814ms to bake 72 animations and a total of 6802 frames_

Took a bit to tweak the setup and dial this in, but we should be able to programmatically render scene in a blocking way (no need to defer to engine loop here it’s all contiguous data) to get the skeleton matrix transformations per animationgroup frame in a loop as fast as possible.

**Part 2: Size (50% reduction)**

Like the logs above show, the VAT I am baking aren’t small - many humanoid models have upwards of 72 animations and the usual method of baking through the core API/Baker producing Float32Array yields vat data around 11mb, compressed 6mb on disk, but nonetheless will need to be decompressed in memory and uploaded to the GPU.

_For my purposes_ (may not suit all needs), using Float16 precision is perfectly fine. It has precision to 3 decimal places and there is no noticeable change in animations from 32 bit to 16 bit precision. The savings, of course, is exactly 50% on disk, memory and GPU memory.

Here is the playground. There are some other artifacts around instancing and texture atlasing, but mainly wanted to showcase:

`bakeVat` - fast VAT baking  
`textureFromBakedVertexDataHalfFloat` - Raw Texture for VAT from half float

> **[Babylon.js Playground](https://playground.babylonjs.com/?BabylonToolkit#T3QKRV%2317)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

Note: The baking here is specific to float16 and would need to be modified as a config param or separate function to bake the normal float32. Would also be a tad quicker with no need to translate the matrix values. This is just a proof of concept.

---

<div class="post-metadata">

**Author:** ![phaselock](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@phaselock](https://forum.babylonjs.com/u/phaselock)\
**Post date:** [June 12, 2025, 8:55am UTC](https://forum.babylonjs.com/t/optimizing-vat-baking-to-near-instant-and-using-float16-for-50-memory-savings/58940/3 "2025-06-12T08:55:11Z")

</div>

cc @Raggar

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [June 12, 2025, 3:20pm UTC](https://forum.babylonjs.com/t/optimizing-vat-baking-to-near-instant-and-using-float16-for-50-memory-savings/58940/4 "2025-06-12T15:20:42Z")

</div>

Woot! We mut introduce it in the engine. Wanna do a PR? we can offer the option to switch to f16 and keep the current precision for instance

---

<div class="post-metadata">

**Author:** ![knervous](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knervous/32/46952_2.png) [@knervous](https://forum.babylonjs.com/u/knervous)\
**Post date:** [June 12, 2025, 7:02pm UTC](https://forum.babylonjs.com/t/optimizing-vat-baking-to-near-instant-and-using-float16-for-50-memory-savings/58940/5 "2025-06-12T19:02:23Z")

</div>

Absolutely! Probably don’t want to fudge with the existing method to avoid breakage… Will throw something up and field some design questions, like if we want it to by sync (stop the world on the main thread - I think this actually makes sense with the benchmarks vs. overhead of throwing this on a worker). Might be a few days til I get to it, on vacation right now.

I made a simpler PG based on the current VAT doc PG comparing the two side by side and loading in the sync VAT

Here are the numbers:

**1013.8999999761581 ms** to render async  
**18.5 ms** to render sync

> **[Babylon.js Playground](https://playground.babylonjs.com/?BabylonToolkit#CP2RN9%23302)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

---

<div class="post-metadata">

**Author:** ![knervous](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knervous/32/46952_2.png) [@knervous](https://forum.babylonjs.com/u/knervous)\
**Post date:** [June 13, 2025, 3:55am UTC](https://forum.babylonjs.com/t/optimizing-vat-baking-to-near-instant-and-using-float16-for-50-memory-savings/58940/6 "2025-06-13T03:55:47Z")

</div>

Got my first Babylon PR up 🙂 [Add faster synchronous method for VAT baking on vertexAnimationBaker by knervous · Pull Request #16749 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/16749)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [June 13, 2025, 4:03pm UTC](https://forum.babylonjs.com/t/optimizing-vat-baking-to-near-instant-and-using-float16-for-50-memory-savings/58940/7 "2025-06-13T16:03:44Z")

</div>

Congrats!

Do you mind updating the doc here:  
[Baked Texture Animations | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/animation/baked_texture_animations/)

Thanks a ton!

---

<div class="post-metadata">

**Author:** ![knervous](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knervous/32/46952_2.png) [@knervous](https://forum.babylonjs.com/u/knervous)\
**Post date:** [June 13, 2025, 4:26pm UTC](https://forum.babylonjs.com/t/optimizing-vat-baking-to-near-instant-and-using-float16-for-50-memory-savings/58940/8 "2025-06-13T16:26:53Z")

</div>

Yep will do soon, thanks!

---

<div class="post-metadata">

**Author:** ![knervous](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/knervous/32/46952_2.png) [@knervous](https://forum.babylonjs.com/u/knervous)\
**Post date:** [June 21, 2025, 5:04am UTC](https://forum.babylonjs.com/t/optimizing-vat-baking-to-near-instant-and-using-float16-for-50-memory-savings/58940/9 "2025-06-21T05:04:46Z")

</div>

Just got around to updated the docs, here is the PR. Still waiting for the update in the Playground for the latest logic change to bakeVertexDataSync so just have it shimmed in the example PG for now. Thanks for the quick feedback! Will look forward to making more engine contributions.

> <https://github.com/BabylonJS/Documentation/pull/1376>
>
> Update docs to reflect new API methods on VertexAnimationBaker for \`bakeVetexDat…aSync\` and \`textureFromBakedVertexData\`
