Block texture compression (BC7 / ASTC)
Fixed-rate GPU block formats such as BC7 on desktop and ASTC on mobile keep textures compressed in video memory, shrinking bandwidth and footprint at some quality loss.
Also known as BC7, ASTC, BCn, Block Compression, BC5, VRAM Texture Compression
In the family Performance, LOD & compression, texture compression
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Built in | new THREE.CompressedTexture(...) with RGBA_ASTC_4x4_Format / RGBA_BPTC_Format docs Transcode via KTX2Loader. |
| Babylon.js 9.38.0 | Built in | KTX2 / DDS compressed texture loaders (BCn/ASTC/ETC2 via KhronosTextureContainer2) docs |
| Godot 4.7 | Built in | Project import: Compress > Mode = VRAM Compressed (BPTC/S3TC/ETC2/ASTC); Image.compress() docs |
| Unity | Built in | Texture Import Settings > Compression / Format (BC7, ASTC) docs Platform-dependent texture compression at import. |
| Unreal 5.7 | Built in | Texture Editor > Compression > Compression Settings (TC_Default DXT1/DXT5, TC_BC7, TC_Normalmap, platform ASTC/ETC2) docs |
| Blender 5.2 | None found | |
| WebGPU W3C | Built in | requiredFeatures: ['texture-compression-bc'] or ['texture-compression-astc']; formats bc7-rgba-unorm, astc-4x4-unorm docs BC, ASTC and ETC2 are optional device features; availability varies by GPU. |
| Metal | Built in | MTLPixelFormat.bc7_rgbaUnorm (macOS) / .astc_4x4_ldr (Apple GPUs) docs ASTC on Apple silicon, BC on Mac GPUs; ETC2 also listed. |
How it works
Images are split into small blocks, 4x4 for BC7 and variable sizes from 4x4 to 12x12 for ASTC. Each block stores two or more endpoint colours, optional partition choices and per-texel weights. The GPU decodes blocks on the fly during sampling, so memory use and fetch bandwidth drop by 4x to over 10x with random access preserved.
Encoders search partitions, modes and weights per block to minimise error; slower settings give better quality. Data is lossy and offline-encoded, with separate handling for normals, HDR and alpha.
When to choose it
Reach for it when
- texture memory is too high on the gpu
- bandwidth bound from sampling big uncompressed textures
- need gpu-native compressed textures for fast sampling
- color banding or blockiness after compressing textures
Choose BC7 for high-quality desktop colour and ASTC where mobile support is needed or flexible bitrates help. Prefer Basis Universal / KTX2 supercompression when one file must transcode to whichever format the device supports. Prefer uncompressed or lossless only for lookup tables and tiny UI.
Field marks
- Block artifacts and colour banding on smooth gradients
- Normals suffer without a dedicated two-channel layout
- Hardware support differs: ASTC absent on many desktop GPUs, BC7 absent on most mobile
- Chroma bleeding at sharp colour edges within a block
Presets
Block Texture Compression (BC7/ASTC) — 4x4 endpoint quantization & partitions (left) vs uncompressed (right)
{
"P_BLOCK_PX": 10,
"P_PARTITIONS": 1,
"P_ERROR_VIS": 0,
"P_SPLIT": 0.5
}Show GLSL (122 lines)
const float P_BLOCK_PX = 10.0; // P Block Size px [4.0, 22.0, 1.0]
const float P_PARTITIONS = 1.0; // P Dual Partition [0.0, 1.0, 1.0]
const float P_ERROR_VIS = 0.0; // P Error Heat Mode [0.0, 1.0, 0.05]
const float P_SPLIT = 0.50; // P Compressed / Source [0.0, 1.0, 0.02]
// High-frequency colorful test chart combining sharp diagonal color edges, smooth gradients & fine rings
vec3 sourceTexture(vec2 uv, float t) {
vec2 p = uv;
float r = length(p - vec2(0.0, 0.02));
float a = atan(p.y - 0.02, p.x);
// Smooth chromatic gradient backdrop
vec3 bg = 0.5 + 0.45 * cos(vec3(0.0, 2.094, 4.188) + p.x * 2.6 + p.y * 1.9 + t * 0.35);
// Sharp contrasting diagonal color bar (classic worst-case for 1-subset BC1/DXT1, solved by BC7 2-subset partitions!)
float diag = p.x * 0.78 + p.y * 0.62 - 0.08 * sin(t * 0.6);
vec3 stripeCol = (diag > 0.0) ? vec3(0.98, 0.34, 0.14) : vec3(0.08, 0.78, 0.88);
float band = smoothstep(0.16, 0.15, abs(diag));
vec3 col = mix(bg * 0.68, stripeCol, band * 0.85);
// Concentric high-contrast metallic rings
float ring = smoothstep(0.024, 0.014, abs(fract(r * 6.5 - t * 0.18) - 0.5));
float inner = smoothstep(0.38, 0.36, r);
vec3 ringCol = mix(vec3(0.96, 0.86, 0.24), vec3(0.86, 0.22, 0.72), 0.5 + 0.5 * sin(a * 4.0));
col = mix(col, ringCol, ring * inner * 0.92);
// Fine checker patch at bottom-left to stress 4x4 block endpoint interpolation
if (p.x < -0.15 && p.y < -0.12) {
float chk = mod(floor(p.x * 26.0) + floor(p.y * 26.0), 2.0);
col = mix(vec3(0.10, 0.14, 0.22), vec3(0.95, 0.90, 0.78), chk);
}
return clamp(col, 0.0, 1.0);
}
// Quantize a single 4x4 block subset along its principal min/max color line (4 levels = 2-bit BC index)
vec3 compressSubset(vec2 blockOrigin, vec2 blockSize, vec2 texelUV, int subsetId, bool dualPart, float t) {
vec3 cMin = vec3(1e5);
vec3 cMax = vec3(-1e5);
vec3 cSum = vec3(0.0);
float count = 0.0;
// Sample 4x4 texels inside the block to fit the endpoint pair (E0, E1)
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 4; x++) {
vec2 local = (vec2(float(x), float(y)) + 0.5) * 0.25;
int sid = (dualPart && (local.x + local.y > 1.0)) ? 1 : 0;
if (sid != subsetId) continue;
vec3 c = sourceTexture(blockOrigin + local * blockSize, t);
cMin = min(cMin, c);
cMax = max(cMax, c);
cSum += c;
count += 1.0;
}
}
if (count < 0.5) return sourceTexture(texelUV, t);
// 5-6-5 / 7-bit endpoint quantization
float qSteps = dualPart ? 31.0 : 15.0;
vec3 e0 = floor(cMin * qSteps + 0.5) / qSteps;
vec3 e1 = floor(cMax * qSteps + 0.5) / qSteps;
// Project current texel onto endpoint line segment (e0 -> e1) and quantize to 2-bit index {0, 1/3, 2/3, 1}
vec3 cur = sourceTexture(texelUV, t);
vec3 axis = e1 - e0;
float denom = dot(axis, axis);
float alpha = (denom > 1e-5) ? clamp(dot(cur - e0, axis) / denom, 0.0, 1.0) : 0.0;
float idx = floor(alpha * 3.0 + 0.5) / 3.0;
return mix(e0, e1, idx);
}
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);
bool isSource = screenX >= split;
float blockPx = clamp(floor(P_BLOCK_PX + 0.5), 4.0, 24.0);
bool dualPart = P_PARTITIONS > 0.5;
float errVis = clamp(P_ERROR_VIS, 0.0, 1.0);
vec3 orig = sourceTexture(uv, iTime);
vec3 col = orig;
if (!isSource) {
// Snap to 4x4 texel block coordinates in screen space
float blockWorld = (blockPx * 4.0) / max(iResolution.y, 1.0);
vec2 bId = floor(uv / blockWorld);
vec2 bLocal = fract(uv / blockWorld);
vec2 bOrigin = bId * blockWorld;
// Quantize current fragment to its 4x4 texel center
vec2 texCenter = (floor(bLocal * 4.0) + 0.5) * 0.25;
vec2 texUV = bOrigin + texCenter * blockWorld;
int sid = (dualPart && (texCenter.x + texCenter.y > 1.0)) ? 1 : 0;
vec3 decoded = compressSubset(bOrigin, vec2(blockWorld), texUV, sid, dualPart, iTime);
// Optional amplified RMS compression error heatmap (shows why 2-subset BC7 beats 1-subset BC1!)
float err = length(decoded - orig) * 4.2;
vec3 errCol = mix(vec3(0.05, 0.14, 0.30), vec3(1.0, 0.36, 0.12), clamp(err, 0.0, 1.0));
errCol = mix(errCol, vec3(1.0, 0.96, 0.45), smoothstep(0.75, 1.4, err));
col = mix(decoded, errCol, errVis);
// Crisp 4x4 block boundary overlay & diagonal partition line if dual-subset active
float bEdge = smoothstep(0.035, 0.008, min(min(bLocal.x, 1.0 - bLocal.x), min(bLocal.y, 1.0 - bLocal.y)));
col = mix(col, vec3(0.04, 0.06, 0.10), bEdge * 0.42);
if (dualPart) {
float pLine = smoothstep(0.025, 0.005, abs(bLocal.x + bLocal.y - 1.0));
col = mix(col, vec3(0.95, 0.98, 1.0), pLine * 0.18);
}
}
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.97, 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 |
|---|---|---|---|
| block-texture-compression-live | Tesla T4 1920x1080 | 18.1× baseline (moderate) · 0.562 ms / 0.580 ms | opengl-timer-query · 36 frames · GPU Weight Atlas · Colab T4 sweep |
| block-texture-compression-live | NVIDIA L4 1920x1080 | 15.3× baseline (moderate) · 0.243 ms / 0.246 ms · 2.3× faster on L4 | opengl-timer-query · Cross-architecture validation |
| block-texture-compression-live | NVIDIA A100-SXM4-40GB 1920x1080 | 11.7× baseline (moderate) · 0.338 ms / 0.339 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Block-compressed tile streaming inside a hardware-filtered virtual texture cache: Packing gigapixel worlds into block-aligned BC7/ASTC 128x128 tiles with 4-texel (1-block) border gutters streams 4x-6x more unique surface detail into a fixed virtual-texture physical page cache while keeping hardware anisotropic filtering seam-free.
- Basis Universal / KTX2 supercompression: Supercompressed KTX2 transcodes at load time into BC7 or ASTC for the device.
Sources
- primary (2014). Adaptive Scalable Texture Compression. GPU Pro 5.Verified via crossref · 2026-11-29doi:10.1201/b16721-26
- implementationARM-software (2015). ARM-software/astc-encoder. The Arm ASTC Encoder, a compressor command line tool and codec library for the Adaptive Scalable Texture Compression image format.GitHub API · license Apache-2.0 · 2026-11-29
- implementationrichgel999 (2021). richgel999/bc7enc_rdo. RDO BC1-7 GPU texture encodersGitHub API · license NOASSERTION · 2026-11-29