src/assets/__docs__/compressed-textures.md
Compressed textures use 4-8x less GPU memory than standard PNG/JPG textures and upload faster, especially on mobile devices or lower-end hardware. PixiJS supports multiple compressed texture formats, but you must register the appropriate loaders before using them.
| Format | File Extension | Best for | Description |
|---|---|---|---|
| DDS | .dds | Desktop, S3TC hardware | DirectDraw Surface format, supports DXT variants (S3TC) |
| KTX | .ktx | Mobile (ETC2/ASTC) | Khronos format, supports ETC and other schemes |
| KTX2 | .ktx2 | Cross-platform (recommended) | Supports Basis Universal and supercompressed formats |
| Basis | .basis | Cross-platform, smallest files | Highly compressed format that transcodes to multiple GPU formats |
PixiJS does not include compressed texture support by default. Import the loaders you need before loading any assets:
import 'pixi.js/dds';
import 'pixi.js/ktx';
import 'pixi.js/ktx2';
import 'pixi.js/basis';
[!NOTE] You only need to import loaders for the formats you use. These imports must run before any call to
Assets.load.
Once loaders are registered, load compressed textures like any other asset:
import 'pixi.js/ktx2';
import { Assets } from 'pixi.js';
await Assets.load('textures/background.ktx2');
PixiJS parses and uploads the texture using the correct loader and GPU-compatible transcoding path based on the user's device.
AssetPack supports automatic generation of compressed texture variants during your build step. You can:
.png or .jpg files into .basis, .ktx2, or .dds formatsYour manifest can include multiple format candidates:
{
"bundles": [
{
"name": "scene",
"assets": [
{
"alias": "bg",
"src": ["assets/bg.ktx2", "assets/bg.basis", "assets/bg.png"]
}
]
}
]
}
PixiJS tries to load bg.ktx2 or bg.basis first if the device supports it, falling back to bg.png as needed.