gltf-rs / gltf

A crate for loading glTF 2.0
Apache License 2.0
532 stars 123 forks source link

Support for KHR_texture_basisu #303

Open IcyDefiance opened 3 years ago

IcyDefiance commented 3 years ago

Support for the KHR_texture_basisu extension would be useful to reduce texture load times across a wide variety of hardware.

Useful links:

Gutawer commented 3 years ago

I've created a fork of this with incredibly basic support for the extension, which I'm using in my own code to load ktx2 files into a wgpu renderer: https://github.com/Gutawer/gltf Right now this is very bare bones and only adds the support on a JSON level (including validating the weird case where a file is only allowed to omit a non-basisu source if it requires and not just uses the extension), and I'm not sure things are done how the library author would want them to be. I'm not quite satisfied myself with my code doing a contains call to check if the extension is required, since it gets done a lot (potentially).

Still, it's a start - with regards to actually loading the files, the ecosystem doesn't seem super well off in this area right now. The best library that supports all the features seems to be libktx_rs, which is what I use, but it's just bindings to Khronos' C++ implementation (which is fine but of course introduces a non-trivial C++ dependency).

I think this extension should initially be implemented in this library without support for the import feature, therefore - especially since handling of KTX2 files would reasonably expect knowledge of the current graphics adapter anyway, since you'd probably want to get the data into a GPU compressed form. Maybe in the future this could be added but it seems difficult to handle generically.