Texture

Texture Compression

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

Usage

In the engine, simply use resourceManager to load:

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

Using ktx2 in glTF requires including the KHR_texture_basisu extension.

KTX2 can be generated using:

  • toktx
  • basisu

Editor

When packaging the project, the editor can configure options to generate KTX2. Refer to the 'Project Release' document. The project export is a global configuration, and different compression formats can be configured independently for different texture resources. Check overwrite in the texture panel of the editor to override the global configuration:

image-20240705112419249
  • ETC1S has a small size and minimal memory usage but lower quality, suitable for albedo, specular, and other maps.
  • UASTC has a larger size and higher quality, suitable for normal maps and similar textures.

Compatibility

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

Was this page helpful?