BinomialLLC / basis_universal

Basis Universal GPU Texture Codec
Apache License 2.0
2.67k stars 261 forks source link

Is image/basis an official MIME type for Basis U? #52

Closed zeux closed 5 years ago

zeux commented 5 years ago

This MIME type is referenced in webgl/gltf/assets/AgiHqSmall.gltf - is this a strawman example or is it/will it be registered as an official MIME type?

donmccurdy commented 5 years ago

I don't know if the .basis extension has an official MIME type yet – I'll defer to @richgel999 on that.

But the GOOGLE_texture_basis extension and that asset are definitely strawman just examples – the actual plan for glTF is https://github.com/KhronosGroup/glTF/pull/1612, via KHR_texture_basisu, in which the Basis payload is in a KTX2 wrapper, using the KTX2 mimetype (TBD?). The GOOGLE_texture_basis references here can all go away when that is specified and implemented.

richgel999 commented 5 years ago

Sorry, I'll have to get more familiar with MIME types before I can really answer this. As .basis file's aren't going anywhere (i.e. the library will always support reading/writing .basis files independent of whatever happens with KTX2). Some users don't want the extra complexity of KTX2.

JordyvanDortmont commented 5 years ago

Coincidentally, I ran into this problem yesterday as well. I noticed that the MIME type defaults to XML in some browsers when sending a .basis file to the client. Another developer more familiar with MIME types suggested the use of image/x.basis for unregistered MIME types, but it would be nice if we could use an official MIME type.

Currently we're using and referring to .basis files as image sources in the glTF instead of wrapping them in KTX2. Is there any benefit to wrapping the .basis files in KTX2?

richgel999 commented 5 years ago

KTX2 will have more information about the colorspace of the source content. It's a higher-level format, and it's going to be a Khronos standard.

However, using KTX2 also brings on more complexity, more code, and possibly more security risks (more parsers).

MarkCallow commented 5 years ago

KTX2 does not wrap the .basis files. It provides a container for the underlying global endpoints, selectors and huffman tables and of course the compressed image data that references the global data. As such there is no duplication of any header information and no need for additional parsers. Only the KTX2 format needs to be parsed.

The specification is more complex because it is more rigorous, e.g. by defining precisely the order of images in the file including levels, layers and faces or depth slices. This actually makes the loader simpler because the images are guaranteed to be in the order needed for upload to WebGL, OpenGL or Vulkan. It also lets KTX2 support externally generated mip levels. The level order has been chosen to support streaming. The smallest level comes first.

zeux commented 5 years ago

Thanks for the answers! I was trying to figure out if there's a Basis embedding story for glTF that doesn't involve KTX2 but it sounds like it's not the case, and image/basis is not an official MIME type.

d-damien commented 4 years ago

Might seem silly, but also can we have a shorter extension ? .bsu ?