Open krispya opened 10 months ago
For other formats (PNG, JPG, WEBP, AVIF) you can use the compressTexture
function. But yes, exposing a nice API for KTX2 compression has been more of a challenge, because it requires shell sessions. This is also why it hasn't become part of the @gltf-transform/functions
package.
Also see:
This would be easier if an suitable npm library existed for KTX2 compression, as it is, I need logic to create temporary scratch directories and so on, which would also need to be handled per-texture here.
I probably will not spend time on this myself unless/until #675 gets unblocked, but I'd be happy to review a PR if someone would like to try splitting toktx()
into separate functions, perhaps textureCompressKTX2
for the transform and compressTextureKTX2
for the single-texture function.
I see, thanks for pointing that out. I am exploring this area now. I'll report back if I discover anything useful
@krispya If it can help the technique I currently use is to save the image data to a file of the texture i want to save, call the ktx cli tools to convert and then push it back to gltftransform.
When creating an asset pipeline there are often situations where I need to transform data, such as compressing individual textures, without it being embedded in a gltf or glb. Instead of cherry picking these functions out of gltf-transform, it would be great if were exported. For example, being able to compress any texture to KTX2 via a node call.