mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.31k stars 35.35k forks source link

Bug - KTX2Loader does not load Basis Textures #24290

Closed SilasReinagel closed 2 years ago

SilasReinagel commented 2 years ago

Version: ThreeJS v142

Reproduction Example: https://github.com/EnigmaDragons/ThreeJS-BasisLoadBug

Relevant ThreeJS Documentation: https://github.com/mrdoob/three.js/wiki/Migration-Guide#136--137 BasisTextureLoader has been deprecated. Please use KTX2Loader instead.

Issue: The deprecation of this feature seems to leave no way for ThreeJS to load straight standard Basis Supercompressed Textures, and the KTX2Loader seems to only work with KTX2 Textures (of which some may be Basis Textures, but it does not seem to open uncontainerized ones).

Error Message from Sample (See Reproduction Example):

ktx-parse.umd.js:1 Uncaught (in promise) Error: Missing KTX 2.0 identifier.
    at _.read (ktx-parse.umd.js:1:11979)
    at KTX2Loader._createTexture (KTX2Loader.js:206:22)
    at Object.onLoad (KTX2Loader.js:168:10)
    at three.js:28469:36
donmccurdy commented 2 years ago

The intention is to eventually end support for files with a .basis extension. They're a non-standard container format, created only by the Basis Universal libraries — which can also export standard .ktx2 files now. The internal image compression data is identical, so there's no advantage to the .basis container. KTX2 supports a wider variety of features, and will be more future-proof in other software. This should also allow us to eventually provide a much smaller WASM transcoder.

So, the warning message is meant to encourage people to produce .ktx2 files instead of .basis files, or at least to be aware that BasisTextureLoader will eventually be removed from a future release.

SilasReinagel commented 2 years ago

Interesting. That all makes good sense.

Then I have two thoughts:

  1. Maybe we could update the documentation to clarify this intent
  2. For those who need legacy support for Basis file, when we go to deprecate the Basis Texture Loader, perhaps it could be forked into a separate repo as a THREE JS Plugin
donmccurdy commented 2 years ago

When using BasisTextureLoader now, a more detailed warning is shown —

https://github.com/mrdoob/three.js/blob/191a1ef699a5d53de2cd645c667e7fee184a18fd/examples/jsm/loaders/BasisTextureLoader.js#L51-L56

If there's anywhere else such warnings should appear, PRs would be welcome!

I'm not planning to maintain BasisTextureLoader.js further myself, but if someone wants to move it into a repository and update it with future three.js versions when needed, that's great. Beyond that it will remain accessible in GitHub under the tags for previous releases as well.