loaders.gl support
| Type | API |
|---|---|
| Loader | CompressedTextureLoader |
| Loader | BasisLoader |
| Writer | CompressedTextureWriter |
| Writer | KTX2BasisWriter |
Portable texture delivery
Package once. Choose the GPU target at runtime.
Containers preserve dimensions and mip levels; portable payloads delay the final format choice until the application knows what the current device supports.
Distributed asset
Runtime choice
metadata · levels · capabilities
Renderer receives
The application keeps one asset pipeline while the renderer receives the representation its WebGL or WebGPU device can use efficiently.
Container responsibilities
Describe how the GPU should read the bytes.
KTX containers carry dimensions, levels, layers, faces, and format information alongside the image payload. The loader exposes that structure instead of reducing it to one ordinary image.
Layouts
2D, 3D, array, and cube texture images
Levels
Mip chains with dimensions and byte sizes
Payloads
Native compressed blocks or Basis supercompression
Runtime
Texture metadata for WebGL, WebGPU, or another renderer
@loaders.gl/images- loaders.gl implementationCompressedTextureLoader- reads KTX and KTX2 containersBasisLoader- decodes Basis-compressed payloads commonly stored in KTX2
KTX is the Khronos texture container format for GPU textures. It is designed to store texture metadata and one or more texture images in a layout that maps cleanly onto graphics APIs.
Detailed guide
KTX structure and runtime support
The sections below compare KTX revisions, describe supported container features, and show the loaders.gl return shapes.
KTX2 is the newer revision of the container. In realtime graphics workflows it is commonly used either for directly stored GPU texture payloads or as a container for Basis Universal supercompressed textures.
Why It Is Used
KTX containers are designed for texture data rather than conventional images:
- they can store mip chains
- they can store array, 3D, and cube texture layouts
- they preserve GPU-oriented format metadata
- they avoid re-encoding texture payloads at load time
KTX vs KTX2
| Format | Status | Notes |
|---|---|---|
| KTX2 | Newer revision | Common in modern realtime pipelines, including use as a container for Basis Universal payloads. |
| KTX | Original revision | Still a Khronos texture container, but less flexible than KTX2 for newer workflows. |
loaders.gl Support
| Format Feature | loaders.gl Support | Notes |
|---|---|---|
| KTX container parsing | ✅ | Supported by CompressedTextureLoader. |
| KTX2 container parsing | ✅ | Supported by CompressedTextureLoader. |
| KTX2 Basis transcoding | ✅ | Use BasisLoader when the KTX2 payload needs Basis transcoding. |
| Mip level extraction | ✅ | Returned as TextureLevel[] or TextureLevel[][] depending on loader. |
| GPU format tagging | ✅ | loaders.gl maps known container formats to WebGL and canonical texture format identifiers. |