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

Extract .basis from ktx2. #318

Open
fire opened this issue Aug 18, 2022 · 6 comments
Open

Extract .basis from ktx2. #318

fire opened this issue Aug 18, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@fire
Copy link

fire commented Aug 18, 2022

We can compress images into ktx2.

basisu::basis_compressor c;
// ...
const basisu::uint8_vec &buvec = c.get_output_ktx2_file();

How do we take a ktx2 and get a basis file with all the mipmaps, layers, and supporting both etc1s and uastc?

Trying to implement basisu in gltf where I convert a gltf ktx2 basisu to the internal storage of a .basis instead of directly to bptc, astc, or dxt5.

@fire
Copy link
Author

fire commented Aug 18, 2022

Working in the https://github.com/V-Sekai/godot/tree/gltfpack-basisu branch.

// https://github.com/V-Sekai/godot/commit/3adfbf559adddf5d5a991ea7a2c03a97f6cc3e65
// This takes a image and outputs a ktx2. Easy.
Vector<uint8_t> (*Image::basis_universal_ktx2_packer_ptr)(const Ref<Image> &, Image::UsedChannels) = nullptr;
// This takes a image and outputs an image which is internally a .basis. Stuck here.
Ref<Resource> (*Image::basis_universal_ktx2_unpacker_ptr)(const uint8_t *, int) = nullptr;

@richgel999
Copy link
Contributor

richgel999 commented Aug 21, 2022

How do we take a ktx2 and get a basis file with all the mipmaps, layers, and supporting both etc1s and uastc?

Is the KTX2 uncompressed? That should be relatively easy, although we would need to write a KTX2 reader. (Which isn't hard, but any parser involves security concerns.)

@richgel999 richgel999 added the enhancement New feature or request label Aug 21, 2022
@fire
Copy link
Author

fire commented Aug 21, 2022

Is a KTX2 reader something that fits this library for purpose of png -> ktx2, and ktx2 -> basis. Not sure where else to fit it. Other devs spent some time converting to basis.

See mosra/magnum-plugins#110

@MarkCallow
Copy link
Contributor

There is already a widely supported KHR_texture_basisu extension for glTF which uses KTX v2 format files. It seems like https://github.com/V-Sekai/godot/tree/gltfpack-basisu is out-of-date or incorrect.

@fire
Copy link
Author

fire commented Sep 28, 2022

Yes, its incorrect, thats the whole point of this bug. I can either implement support or close.

@MarkCallow
Copy link
Contributor

Or you can use a non-broken gltf pack tool.

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

No branches or pull requests

3 participants