Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose functionality to compress individual textures #1162

Open
krispya opened this issue Nov 9, 2023 · 3 comments
Open

Expose functionality to compress individual textures #1162

krispya opened this issue Nov 9, 2023 · 3 comments
Labels
feature New enhancement or request package:cli

Comments

@krispya
Copy link

krispya commented Nov 9, 2023

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.

@krispya krispya added the feature New enhancement or request label Nov 9, 2023
@donmccurdy
Copy link
Owner

donmccurdy commented Nov 9, 2023

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.

@krispya
Copy link
Author

krispya commented Nov 9, 2023

I see, thanks for pointing that out. I am exploring this area now. I'll report back if I discover anything useful

@Makio64
Copy link
Contributor

Makio64 commented Nov 14, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New enhancement or request package:cli
Projects
None yet
Development

No branches or pull requests

3 participants