Loader category
Get texture payloads ready for the GPU.
Texture loaders preserve the details that ordinary image loaders do not: mip levels, array and cube layouts, compression formats, and the metadata a runtime needs to choose a supported GPU representation.
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, payload, runtime
Keep the texture pipeline explicit.
A KTX2 or Basis asset is a delivery container, not necessarily the final GPU format. loaders.gl exposes the levels and metadata, then can transcode to a device-compatible representation.
Containers
KTX, KTX2, DDS, PVR, and Basis
Layouts
Mip chains, arrays, cube maps, and 3D textures
Transcoding
Basis Universal to a supported runtime format
Output
TextureLevel data or normalized texture objects
The texture loader category documents the common return shapes, conventions, and helper APIs used for compressed and GPU-oriented texture assets under loaders.gl conventions.
Detailed guide
Texture data and format details
The sections below cover category loaders, normalized return shapes, container formats, and writer behavior.
Texture Category Loaders
| Loader | Notes |
|---|---|
CompressedTextureLoader | Parses KTX, DDS, and PVR texture containers |
BasisLoader | Transcodes Basis assets into runtime texture formats |
RadianceHDRLoader | Decodes Radiance .hdr textures into floating-point texture data |
CrunchLoader | Decodes Crunch compressed mip chains |
TextureLoader | Loads manifest-driven single image textures and mip chains |
TextureArrayLoader | Loads manifest-driven texture arrays |
TextureCubeLoader | Loads manifest-driven cubemaps |
TextureCubeArrayLoader | Loads manifest-driven texture cube arrays |
Core texture category support is provided by the @loaders.gl/images module.
Texture Types
Texture loaders in this category return normalized texture payloads from @loaders.gl/core/schema.
| Type | Shape | Description |
|---|---|---|
TextureLevel[] | Array of mip levels | Used by CompressedTextureLoader and CrunchLoader for a single texture image. |
TextureLevel[][] | Array of images, each with mip levels | Used by BasisLoader when an asset contains multiple logical images. |
Texture | Object with shape: 'texture' | Used by RadianceHDRLoader and manifest-driven texture loaders. |
A TextureLevel describes one mip level of one texture image.
| Field | Type | Description |
|---|---|---|
compressed | boolean | Whether the mip level data is GPU-compressed. |
shape | 'texture-level' | Shape tag for normalized texture-level payloads. |
format | number | WebGL internal format enum for the level. |
textureFormat | TextureFormat | WebGPU / luma.gl style format string for the data. |
data | TypedArray | The payload for this mip level. Compressed texture loaders return Uint8Array; RadianceHDRLoader returns Float32Array. |
width | number | Width of this mip level. |
height | number | Height of this mip level. |
levelSize | number | Size in bytes for this mip level, when available. |
hasAlpha | boolean | Whether the transcoded or decoded texture contains alpha. |
Compressed Texture Data
Compressed texture payloads are not directly indexable pixel arrays. Their data field contains bytes in the texture container or GPU block-compressed format represented by the format / textureFormat metadata.
Applications that need ordinary raster pixel access should use the Image Loaders category instead.
Composite Texture Members
Manifest-driven texture loaders resolve member images through ImageLoader. Member assets return native ImageBitmap in browsers and the installed Node.js ImageBitmap polyfill when @loaders.gl/core/polyfills is present.
Usage
import {load} from '@loaders.gl/core';
import {BasisLoader} from '@loaders.gl/images/basis';
const images = await load('texture.ktx2', BasisLoader, {
basis: {
format: 'auto',
supportedTextureFormats: ['bc3-rgba-unorm']
}
});
Notes
About image loaders
Standard raster image loading, getImageData(image), and the Node.js ImageBitmap polyfill used by ImageLoader are documented separately in Image Loaders.