Basis Universal / KTX2 supercompression
A supercompressed texture format stored in KTX2 that transcodes at load time into whichever GPU format the device supports, such as BC7, ASTC or ETC2.
Also known as Basis Universal, KTX2, UASTC
In the family Performance, LOD & compression, texture compression
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js' docs |
| Babylon.js 9.38.0 | Built in | KhronosTextureContainer2 / KHR_texture_basisu loader (KTX2 Basis transcoding) docs |
| Godot 4.7 | Built in | Import dock > Compress > Mode = Basis Universal (stores KTX2/UASTC/ETC1S) docs |
| Unity | Official add-on | Package Manager > KTX for Unity (com.unity.cloud.ktx) docs Official Unity package (KTX 2.0 / Basis Universal). |
| Unreal 5.7 | None found | Unreal uses Oodle Texture and platform BC/ASTC/ETC2 compression rather than KTX2/Basis Universal. |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The encoder writes an intermediate format, either ETC1S for small files or UASTC for high quality, then compresses it further with Zstandard in a KTX2 container. At load, a small WebAssembly or native transcoder converts blocks directly into the target GPU block format with little work per block, and the result uploads without decoding to RGBA.
One asset therefore ships to browsers and devices with different texture support, giving small download sizes and small video memory use at once.
When to choose it
Reach for it when
- textures too large to download in a web app
- one texture file must work on desktop and mobile gpus
- gltf textures eat vram and load slowly
- don't know which gpu compressed format the device supports
Choose it for web and cross-platform delivery where the target format is unknown, for example glTF with KHR_texture_basisu. Prefer Block texture compression (BC7 / ASTC) pre-encoded per platform when you control the device set and want the best quality. Prefer PNG or JPEG for size-insensitive small textures.
Field marks
- ETC1S shows blocky colour and loses fine detail, especially on normals
- Transcoding adds load-time latency without a worker
- Quality at a given size is below a dedicated encoder per format
- Alpha and HDR need extra care
Presets
Basis Universal / KTX2 — 4x4 ETC1S codebook endpoint quantization (left) vs transcoded UASTC/BC7 PBR shading (right)
{
"P_BLOCK_SCALE": 6,
"P_QUANT_LEVELS": 0.55,
"P_GRID_VIS": 0.5,
"P_SPLIT": 0.48
}Show GLSL (123 lines)
const float P_BLOCK_SCALE = 6.00; // P 4x4 Block Scale [2.0, 12.0, 0.5]
const float P_QUANT_LEVELS = 0.55; // P Endpoint Quant [0.15, 1.0, 0.05]
const float P_GRID_VIS = 0.50; // P Block Grid Vis [0.0, 1.0, 0.05]
const float P_SPLIT = 0.48; // P ETC1S / UASTC [0.0, 1.0, 0.02]
vec2 rot2(vec2 p, float a) {
float c = cos(a);
float s = sin(a);
return vec2(c * p.x - s * p.y, s * p.x + c * p.y);
}
// Rich multi-frequency PBR surface albedo + micro-normal texture mapped onto sphere
vec3 evalTexAlbedo(vec2 tuv) {
vec2 p = tuv * 5.0;
float wave = sin(p.x * 3.0 + sin(p.y * 2.4) * 1.6) * 0.5 + 0.5;
float rings = smoothstep(0.35, 0.65, sin(length(fract(p * 0.5) - 0.5) * 28.0));
vec3 cA = vec3(0.14, 0.52, 0.78);
vec3 cB = vec3(0.94, 0.44, 0.18);
vec3 cC = vec3(0.92, 0.86, 0.68);
vec3 base = mix(cA, cB, wave);
return mix(base, cC, rings * 0.42);
}
float luma(vec3 c) {
return dot(c, vec3(0.299, 0.587, 0.114));
}
// Simulate 4x4 GPU block compression (ETC1S single-color-endpoint + 2-bit intensity modifier per texel)
vec3 encodeETC1SBlock(vec2 tuv, float blocksPerUnit, float quantStr) {
vec2 bCoord = tuv * blocksPerUnit;
vec2 bId = floor(bCoord);
vec2 sub = floor(fract(bCoord) * 4.0) / 4.0;
vec2 blockCenter = (bId + 0.5) / blocksPerUnit;
// Compute block mean chroma endpoint (ETC1S shares one base RGB555 endpoint per 4x4 block!)
vec3 c0 = evalTexAlbedo((bId + vec2(0.25, 0.25)) / blocksPerUnit);
vec3 c1 = evalTexAlbedo((bId + vec2(0.75, 0.25)) / blocksPerUnit);
vec3 c2 = evalTexAlbedo((bId + vec2(0.25, 0.75)) / blocksPerUnit);
vec3 c3 = evalTexAlbedo((bId + vec2(0.75, 0.75)) / blocksPerUnit);
vec3 baseEp = (c0 + c1 + c2 + c3) * 0.25;
float bits = mix(14.0, 4.0, quantStr);
baseEp = floor(baseEp * bits + 0.5) / bits;
// Per-texel 2-bit selector modifies only luminance around the shared block endpoint
vec3 texVal = evalTexAlbedo((bId + sub + 0.125) / blocksPerUnit);
float dL = luma(texVal) - luma(baseEp);
float sel = floor(clamp(dL * 5.0 + 2.0, 0.0, 3.0)) - 1.5;
return clamp(baseEp + vec3(sel * 0.10), 0.0, 1.0);
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float screenX = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
float bScale = clamp(P_BLOCK_SCALE, 2.0, 14.0);
float qStr = clamp(P_QUANT_LEVELS, 0.1, 1.0);
float gVis = clamp(P_GRID_VIS, 0.0, 1.0);
vec3 ro = vec3(0.0, 0.22, 2.15);
vec3 rd = normalize(vec3(uv.x, uv.y - 0.05, -1.48));
vec3 lDir = normalize(vec3(0.58, 0.72, 0.52));
vec3 col = mix(vec3(0.05, 0.07, 0.11), vec3(0.14, 0.19, 0.28), smoothstep(-0.5, 0.5, uv.y));
// Textured floor swatch showing flat 4x4 KTX2 texel blocks clearly
float tMin = 1e5;
int hitId = 0;
vec3 hp = vec3(0.0);
vec3 hn = vec3(0.0, 1.0, 0.0);
vec2 tuv = vec2(0.0);
if (rd.y < -0.005) {
float tf = (-0.54 - ro.y) / rd.y;
if (tf > 0.05 && tf < 14.0) {
tMin = tf; hitId = 1; hp = ro + rd * tf; hn = vec3(0.0, 1.0, 0.0);
tuv = hp.xz * 0.42 + vec2(iTime * 0.05, 0.0);
}
}
// Hero rotating PBR sphere showcasing transcoded KTX2 texture fidelity
vec3 sc = vec3(0.0, 0.02, 0.0);
vec3 oc = ro - sc;
float b = dot(oc, rd), d = b * b - (dot(oc, oc) - 0.54 * 0.54);
if (d > 0.0) {
float ts = -b - sqrt(d);
if (ts > 0.05 && ts < tMin) {
tMin = ts; hitId = 2; hp = ro + rd * ts; hn = normalize(hp - sc);
vec3 rn = hn;
rn.xz = rot2(rn.xz, iTime * 0.35);
tuv = vec2(atan(rn.z, rn.x) / 6.2831853 + 0.5, acos(clamp(rn.y, -1.0, 1.0)) / 3.1415926);
}
}
if (hitId > 0) {
float blocks = bScale * (hitId == 2 ? 4.5 : 3.2);
vec3 alb;
float gridLine = 0.0;
if (screenX < split) {
// Left: Low-bitrate ETC1S supercompressed 4x4 block endpoints + block boundary grid
alb = encodeETC1SBlock(tuv, blocks, qStr);
vec2 bf = fract(tuv * blocks);
gridLine = smoothstep(0.06, 0.015, min(min(bf.x, 1.0 - bf.x), min(bf.y, 1.0 - bf.y)));
} else {
// Right: High-quality UASTC -> BC7/ASTC GPU-native transcoded texture with crisp micro-details
alb = evalTexAlbedo(tuv);
}
float ndl = max(dot(hn, lDir), 0.0);
float spec = (hitId == 2) ? pow(max(dot(reflect(-lDir, hn), -rd), 0.0), 36.0) * 0.72 : 0.0;
float fres = (hitId == 2) ? pow(1.0 - max(dot(hn, -rd), 0.0), 4.0) * 0.45 : 0.0;
vec3 shaded = alb * (0.24 + 0.96 * ndl) + vec3(0.85, 0.92, 1.0) * (spec + fres);
shaded = mix(shaded, vec3(0.18, 0.94, 1.0), gridLine * gVis * 0.55);
col = (hitId == 1) ? mix(col, shaded, exp(-tMin * 0.14)) : shaded;
}
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.98, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| basis-universal-ktx2-live | Tesla T4 1920x1080 | 3.53× baseline (light) · 0.116 ms / 0.117 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| basis-universal-ktx2-live | NVIDIA L4 1920x1080 | 3.03× baseline (light) · 0.048 ms / 0.049 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| basis-universal-ktx2-live | NVIDIA A100-SXM4-40GB 1920x1080 | 2.53× baseline (light) · 0.073 ms / 0.073 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Draco mesh compression: Both shrink glTF delivery size: one compresses geometry, the other textures.
Sources
- primaryBinomialLLC (2019). BinomialLLC/basis_universal. Basis Universal GPU Texture CodecGitHub API · license Apache-2.0 · 2026-11-29
- primaryMark Callow. KTX File Format Specification Version 2.0. registry.khronos.org.Verified via live page · 2026-11-29
- implementationKhronosGroup (2013). KhronosGroup/KTX-Software. KTX (Khronos Texture) Library and ToolsGitHub API · license NOASSERTION · 2026-11-29