BabylonJS Vram usage versus Unity

Problem solved

Use DDS instead of compressed JPGs in your projects!

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

1 Like

solved

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

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 :slight_smile:

solved

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.

1 Like

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

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.

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

2 Likes

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.

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.

1 Like

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

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.

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

2 Likes

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:

Is that something that Babylon could be allowed to use ?

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

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.

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

1 Like

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