Files
engine/docs/en/graphics/texture/compression.md
2024-07-17 14:03:06 +08:00

1.5 KiB

order, title, type, group, label
order title type group label
4 Texture Compression Graphics Texture Graphics/Texture

KTX2 (Khronos Texture Container version 2.0) is the latest texture compression solution introduced by Khronos, supported by Galacean since version 1.1. KTX2 will transcode to the corresponding format of compressed textures (BC/PVRTC/ETC/ASTC) based on the device platform support at runtime.

Usage

In the engine, simply load using resourceManager:

engine.resourceManager.load("xxx.ktx2");
// 或
engine.resourceManager.load<Texture2D>({
  type: AssetType.KTX2,
  url: "xxx.ktx2",
}).then(tex=>{
  material.baseTexture = tex;
})

To use KTX2 in glTF, the KHR_texture_basisu extension must be included.

KTX2 generation can be done using:

Compatibility

KTX2 transcoding utilizes WebAssembly technology, requiring Chrome 57+ and iOS 11.3+ (WebAssembly in 11.0 ~ 11.2 has a bug).

For systems below iOS 16, there is a chance of no return when loading the necessary KTX2 parsing wasm file through a worker, especially when loading wasm for the first time. This can be bypassed by not using a worker on iOS:

WebGLEngine.create({ canvas: "canvas", ktx2Loader: { workerCount: 0 } });