Skip to main content

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.

Runtime choice

mipsdevicetranscode

metadata · levels · capabilities

Renderer receives

BC / S3TCdesktop GPU target
ETC2 / ASTCmobile GPU target
Fallback pixelswhen compression is unavailable

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

From-v5.0

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​

LoaderNotes
CompressedTextureLoaderParses KTX, DDS, and PVR texture containers
BasisLoaderTranscodes Basis assets into runtime texture formats
RadianceHDRLoaderDecodes Radiance .hdr textures into floating-point texture data
CrunchLoaderDecodes Crunch compressed mip chains
TextureLoaderLoads manifest-driven single image textures and mip chains
TextureArrayLoaderLoads manifest-driven texture arrays
TextureCubeLoaderLoads manifest-driven cubemaps
TextureCubeArrayLoaderLoads 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.

TypeShapeDescription
TextureLevel[]Array of mip levelsUsed by CompressedTextureLoader and CrunchLoader for a single texture image.
TextureLevel[][]Array of images, each with mip levelsUsed by BasisLoader when an asset contains multiple logical images.
TextureObject with shape: 'texture'Used by RadianceHDRLoader and manifest-driven texture loaders.

A TextureLevel describes one mip level of one texture image.

FieldTypeDescription
compressedbooleanWhether the mip level data is GPU-compressed.
shape'texture-level'Shape tag for normalized texture-level payloads.
formatnumberWebGL internal format enum for the level.
textureFormatTextureFormatWebGPU / luma.gl style format string for the data.
dataTypedArrayThe payload for this mip level. Compressed texture loaders return Uint8Array; RadianceHDRLoader returns Float32Array.
widthnumberWidth of this mip level.
heightnumberHeight of this mip level.
levelSizenumberSize in bytes for this mip level, when available.
hasAlphabooleanWhether 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.