question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

First-class support for Basis textures in glTF

See original GitHub issue

I’m looking into adding support for encoding textures using BasisU to gltfpack and wondering what the plan is for Basis support in glTF.

Right now three.js can load Basis encoded textures from glTF if:

  1. The texture is specified as a URI with .basis extension
  2. BasisTextureLoader is added as a handler for .basis extension

However, there does not seem to be any way to do this if the image is embedded - mimeType is effectively ignored as far as I can tell when loading embedded images, so you can’t specify a handler.

There is an upcoming KHR_image_ktx2 extension that will allow including Basis files wrapped in a KTX2 header, however if the image is embedded then it will have a MIME type of image/ktx2 and, again, some special logic will be necessary to load this.

Just wondering what the plan for supporting all of this is, and if I can help in some way.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
donmccurdycommented, Jul 29, 2019

The plan for glTF is https://github.com/KhronosGroup/glTF/pull/1612. That was recently updated, see KHR_texture_basisu. The extension specification is stable enough for prototyping, although I don’t have any example KTX2 assets yet.

I expect the changes required for three.js will be relatively minor, similar to the current MSFT_texture_dds extension – which I think we should remove support for, actually, since it is really for Microsoft tools. The API might be:

var loader = new THREE.GLTFLoader();
loader.setBasisTextureLoader( new THREE.BasisTextureLoader() );
loader.load( 'model.glb', function ( gltf ) { ... } );

For now this will require a bit of Basis-aware logic in GLTFLoader, like:

https://github.com/mrdoob/three.js/blob/d3808533e8fc7fe23937b3bb8819bd44f7263f8e/examples/js/loaders/GLTFLoader.js#L1972-L1980

https://github.com/mrdoob/three.js/blob/d3808533e8fc7fe23937b3bb8819bd44f7263f8e/examples/js/loaders/GLTFLoader.js#L2004-L2012

With the proposal in https://github.com/mrdoob/three.js/issues/11682, this could be done through a plugin system, but that’s probably a longer-term direction and not necessary for this.

0reactions
donmccurdycommented, Jul 29, 2019

I’m assuming that this also means that there are no plans to support Basis files outside of the KTX container through the glTF flow fully.

Correct, I don’t believe a glTF extension will reference .basis files or mime types directly. Only within a KTX2 container. Feedback on https://github.com/KhronosGroup/glTF/pull/1612 is welcome if you have any concerns about that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basis Universal Texture Format in Unity - Unity Forum
Basis supports texture arrays, and texture arrays are now (finally) a first class citizen with Unity 2020.2, so it's plausible it could be ......
Read more >
Support Other Textures in GLTFLoader - Questions - Babylon.js
I use Basis texture compression format to replace all png textures, and replace all '.png' to '.basis' inside gltf file. glTFLoader.js.
Read more >
Khronos Ratifies KTX 2.0 - Phoronix
KTX 2.0 adds support for Basis Universal compression to the specification. These KTX 2.0 compressed textures can then be used by OpenGL, Vulkan, ......
Read more >
Magnum 2019.10 released
The new release brings Python bindings, Basis Universal texture compression, improved STL interoperability, better Unicode experience for ...
Read more >
GLTF Exporter for SolidEdge - ProtoTech Solutions
GLTF format 2.0; Both part and assembly models Export; Supports GLB file. Supports Partial Texture export; Control the visibility of nodes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found