# BabylonJS Vram usage versus Unity

**URL:** <https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437>\
**Category:** Questions\
**Created:** [May 22, 2019, 8:14am UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437 "2019-05-22T08:14:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 8:14am UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/1 "2019-05-22T08:14:07Z")

</div>

Problem solved

Use DDS instead of compressed JPGs in your projects!

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 22, 2019, 1:09pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/2 "2019-05-22T13:09:14Z")

</div>

I will have a look today with @Deltakosh. I suspect texture are somehow different in both environments.

---

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 1:33pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/3 "2019-05-22T13:33:43Z")

</div>

solved

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 22, 2019, 1:41pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/4 "2019-05-22T13:41:45Z")

</div>

I totally agree and it is why I am digging more into it. I wonder if it could come from the way the textures load or some kind of cache.

The total texture memory should be around 400Mb so we have around 5 times that and it sounds like way too much

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 22, 2019, 1:44pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/5 "2019-05-22T13:44:28Z")

</div>

Could you share with me your babylon scene in a zip file ? this would help a lot for my troubleshooting. I would like to avoid doing it manually 🙂

---

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 2:01pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/6 "2019-05-22T14:01:56Z")

</div>

solved

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 22, 2019, 2:15pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/7 "2019-05-22T14:15:57Z")

</div>

First Unity relies on compressed texture which is far smaller than jpg or png on the GPU. Using a compression DXT5 for most of the textures they have a 4:1 allowed compression ratio.

This alone can explain the gap but I continue to dig in just in case.

---

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 2:18pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/8 "2019-05-22T14:18:15Z")

</div>

Going to try unselecting compression on textures and rebuilding in Unity, this is the easiest test at the moment.

---

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 2:25pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/9 "2019-05-22T14:25:45Z")

</div>

![uncompress](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/d/dd96f82c994321abd891731bd5bfa2aa9bfdfbf2.jpeg)

Interesting! So it might be entirely possible that it’s all down to compression ! Even though its weird that the source files themselves are only 57mb.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 22, 2019, 2:39pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/10 "2019-05-22T14:39:57Z")

</div>

57 MB for 170 textures with half 1024 \* 1024 and half 2048 \* 2048.

So roughly (1024 \* 1024 + 2048 \* 2048) \* 85 \* 4 \* 1.33 which is close to 2Gb

---

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 2:41pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/11 "2019-05-22T14:41:57Z")

</div>

Well I’m not sure what Unity does but its magic. My jpgs are already compressed and are smaller size than the resulting dtx5 or even dtx1(8:1 compression) dds files. So how does Unity do it.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 22, 2019, 2:47pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/12 "2019-05-22T14:47:27Z")

</div>

JPG are fully uncompressed in VRAM so even if pretty tiny for transport, they end up pretty fat on GPU. On the opposite DXT might be bigger for transport but they keep the same size on GPU.

---

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 2:48pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/13 "2019-05-22T14:48:00Z")

</div>

Gotcha, trying out dtx1 dds files now, will see how they fare.

---

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 2:54pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/14 "2019-05-22T14:54:48Z")

</div>

Beautiful, worked like a charm! Thank you for filling the gap in my knowledge.

So all unity does is convert all textures to the dds format.

---

<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:** [May 22, 2019, 3:11pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/15 "2019-05-22T15:11:17Z")

</div>

Good catch team:)  
We are discussing with @sebavan about adding an option in our Exporters to convert texture to compressed ones

---

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 3:16pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/16 "2019-05-22T15:16:51Z")

</div>

So after ending up with 250mbs of textures (instead of 57mbs i had with jpgs) in dtx1 format, but which now uses 4 times less vram, I got to reading, turns out Unity uses this thing here:

> **[Unity-Technologies/crunch](https://github.com/Unity-Technologies/crunch/tree/unity)**
>
> Advanced DXTc texture compression and transcoding library - Unity-Technologies/crunch

> **[Updated Crunch texture compression library – Unity Blog](https://blogs.unity3d.com/2017/11/15/updated-crunch-texture-compression-library/)**
>
> Crunch is a lossy texture compression format, which is normally used on top of DXT texture compression. Crunch compression helps to reduce the size of the ...

Is that something that Babylon could be allowed to use ?

---

<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:** [May 22, 2019, 3:19pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/17 "2019-05-22T15:19:10Z")

</div>

We are the runtime engine not the ddc tools. This is why I tend to leave the creation tools off Babylon.js engine. We do support compressed textures but it is up to the artist to correctly setup the scene.

That being said, I think this kind of tech could be useful in the exporters themselves for sure but with a warning:dxtc works only on windows

---

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 3:23pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/18 "2019-05-22T15:23:43Z")

</div>

Makes sense !

Hoping that you amazing folks at Babylon will help us automate that optimization process somewhat in the future.

Will have to try and get crunch or some other form of compression working for now, since what was a relatively small project before (with 57mb of jpgs on standard materials) will easily turn into 600mb when made with dds, pbr and lightmaps and that is simply too much for the web.

---

<div class="post-metadata">

**Author:** ![somerandomguy83](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/somerandomguy83/32/2624_2.png) [@somerandomguy83](https://forum.babylonjs.com/u/somerandomguy83)\
**Post date:** [May 22, 2019, 3:56pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/19 "2019-05-22T15:56:12Z")

</div>

Regardless, huge thanks for helping me quickly solve my issue.

---

<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:** [May 22, 2019, 4:21pm UTC](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437/20 "2019-05-22T16:21:00Z")

</div>

no worries 🙂 If you end up having a script or something that we can share with other on our documentation, feel free to let me know 🙂

[Next page](https://forum.babylonjs.com/t/babylonjs-vram-usage-versus-unity/3437.md?page=2)
