Support decompressing KTX2 textures
Describe the bug KTX2 textures are not converted when demanded using the CLI.
To Reproduce Steps to reproduce the behavior:
-
gltf-transform mozjpeg input.glb output.glb(input.glb must have KTX2 textures) - File size is identical and still fails the validator with "unknown mimetype image/ktx2".
Expected behavior All textures would now be jpegs.
Versions:
- Version: 2.1.5
- Environment: OSX CLI
Additional context
webp had the same result. Does it not read KTX textures? Also, would be nice if you could set multiple flags; like if my input is draco compressed, it gets uncompressed if I change the textures and then I have to recompress it. Might be nice to put gltf-transform -draco -webp input.glb output.glb.
I'd love to be able to decompress KTX2 textures in glTF-Transform, but I don't see that landing until https://github.com/KhronosGroup/Basis-Universal-Transcoders supports at least converting UASTC and ETC1S to RGBA32. If https://github.com/GoogleChromeLabs/squoosh/pull/1017 landed, that might also fix the issue. In the meantime, yes, .ktx2 files will be ignored by the squoosh-based compression.
For now, the library can convert anything @squoosh/lib can read. That does include WebP, but you'll have to opt-in to changing formats, since the mozjpeg and oxipng commands affect only JPEG and PNG textures respectively by default:
gltf-transform mozjpeg input.glb output.glb --formats "*"
... it gets uncompressed if I change the textures and then I have to recompress it...
So far I've made this explicit because re-applying Draco compression is (I expect?) going to compound the compression artifacts. Seems better to be really explicit about that danger, and the same applies to Meshopt compression.
See also https://github.com/BinomialLLC/basis_universal/issues/318 and from basisu to png.
Unfortunately I'm blocked on this, as no cross-platform packages appear to support decoding UASTC and ETC1S to RGBA32, without bringing in GL-related dependencies. Such dependencies, like headless-gl, are unfortunately too heavy and complex for this library to rely on. If the situation changes I'd be glad to reopen this.
Just filed a request, feel free to upvote. :)
- https://github.com/KhronosGroup/Basis-Universal-Transcoders/issues/20
I'm hoping ETC1S → RGBA8 could be prioritized on the KhronosGroup/Basis-Universal-Transcoders list, which would unblock us using the lightweight transcoders for applications that just need to decode to RGBA8 from UASTC or ETC1S.