How do I make "gltf-transform uastc input.glb output.glb" preserve alpha channels in my image textures?

Basically the title, but everytime I try to compress my model’s image textures to use KTX2 textures using this command gltf-transform uastc input.glb output.glb my PNG image textures lose their alpha channel when converted to KTX2. When I seperate the GLB file using gltf-pipeline -i naw.glb -s and view the KTX2 texture in a viewer the alpha channel just shows full white meaning there’s no longer alpha information.

Is there a parameter that allows me to keep the alpha channel information when compressing?

If the alpha channel is being used somewhere in the model, it shouldn’t be dropped, and it would be a bug if so. If you can share the .glb and want to file a bug at Issues · donmccurdy/glTF-Transform · GitHub that would be welcome. You can find the code responsible for preserving the alpha channel here:

I haven’t really used any KTX2 viewers, but one way to check would be the ktx info mytexture.ktx2 commandline tool, looking for the “KHR_DF_FLAG_ALPHA_STRAIGHT” flag in the output.

2 Likes

I’ll look into it and make an update! Appreciate it knowing this is probably an issue on my end.

Yep, the issue was I exported the material from Blender without using the alpha channel of the principled BSDF node. I plugged the alpha channel of the image texture into the alpha channel of the Principled BSDF, rexported, and the compression worked properly and kept the alpha data.

Appreciate you!!! Your work is amazing haha.

1 Like