How to use compressed textures with blender-exported glTF?

Hi!

I’m trying to reduce the memory that my application uses by using DDS textures with models that are exported from blender using the glTF exporter.
Generating DDS textures and using them in blender is no problem - the problem exists when I’m trying to export the models. It seems that the glTF-Exporter doesn’t support textures other than .jpg and .png, sadly.
Preferably, I would like the textures to be separate from the gltf/glb file, because multiple models will be using the same texture, so it seems wasteful in filesize-terms to embed the same texture into 10 different models.

So I’m wondering if there’s a workflow that supports exporting models that use DDS textures from blender as separate textures/mesh data.
The closest I’ve come is using https://github.com/microsoft/glTF-Toolkit but this embeds the compressed textures into the output file.

1 Like

Just to be sure you’re aware – DDS compressed textures are not supported on all hardware, and in particular support is generally missing on mobile devices: https://docs.unity3d.com/Manual/class-TextureImporterOverride.html (not quite the same but where DXT is mentioned, read DDS).

You might be able to use glTF-Toolkit to make the embedded version and then split it apart with glTF-Pipeline. I’m not sure if that is supported by glTF-Pipeline but it’s worth a try. The glTF DDS extension is only really meant for use in Microsoft products, and tools like the Blender exporter do not support it. We implemented it in three.js only because there were no alternatives for a long time, but that support will likely be dropped in the future (see below).

glTF will have real compressed texture support later this year, using Basis with the ability to transcode quickly into compressed textures appropriate for practically any device, and I would strongly expect that to be supported in lots of libraries.

1 Like

Thanks! I’m using BC1 Compression which if I’m reading the table right, at the bottom at ‘All supported Texture compression formats’ DXT1 is supported, not sure if those are different, though.
Edit: BC1 and DXT1 are not the same.

Good shout on the glTF-Pipeline, I’ll give that a try.
And Basis sounds promising. I read the quick slideshow on it a while back that was presented at the WebGL/glTF Meetup (link) and I can’t wait for it. But for now, I have to explore other options :slight_smile:

Thanks again!

I don’t think most iPhones support anything but PVRTC, but I can’t find a full table of support right now.

another table: https://github.com/TimvanScherpenzeel/texture-compressor/blob/master/docs/SUPPORTED_DEVICES_TABLE.md

1 Like

Little addition^^: You would need at least three texture compression standards (S3TC, PVRTC and ETC1) to support a wide range of devices. In most cases, you also want to use the modern ASTC if the hardware supports it. So you end up with four different formats. Against this backdrop, something like Basis makes it much easier to benefit from texture compression.

Realistically I’m only trying to solve the problem of running out of memory on one device right now, the Kindle Fire 7 from 2015. So using a compression format like DXT1 which has full android support should work. But it seems like the glTF-Toolkit only compresses into BC1/BC5/BC7.
So this has no success story, not until glTF with Basis drops, anyway. I’ll find other ways to increase performance. Thanks though, everyone :slight_smile:

I wonder if it’ll be smart to replace the textures of meshes as soon as they get loaded with glTF loader. Do you know if that would still cause the original texture to get loaded into memory? @Mugen87 @donmccurdy
I don’t add the mesh to the scene as soon as I load it, so it’s not being rendered until a while afterwards.

Are you asking about Basis? The texture is never decompressed – it remains compressed even in GPU memory.

No sorry, I meant just in general. If I were to load a mesh with a jpg texture and once its loaded, replace its texture with a compressed one loaded with THREE.DDSLoader

It would be better to skip the JPG texture entirely in that case (why download it?), but yes, if you remove a texture from the model before the first render that texture won’t be uploaded to the GPU.

1 Like

@donmccurdy Do we know when is basis going to be integrated into the GLTF (and hopefully the blender gltf exporter :innocent:)?
I tried using the r106 basis texture loader but im not really sure which settings exactly to use to avoid artifacts. Besides switching up model textures on load seems inconvenient as well.

I don’t have a time estimate for glTF adding support for this new format, sorry. In the meantime textures must be loaded separately yes.

1 Like