---
id: "block-texture-compression"
title: "Block texture compression (BC7 / ASTC)"
aliases: [BC7, ASTC, BCn, Block Compression, BC5, VRAM Texture Compression]
domain: "performance"
stage: "performance"
realtime: "offline"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal]
year_introduced: 2012
inputs: [texture]
outputs: [texture]
style: "both"
dynamic: "both"
cost: "cheap"
authority: "2014"
url: "https://texelatlas.vercel.app/t/block-texture-compression/"
sources_verified_at: "2026-11-29"
---
# Block texture compression (BC7 / ASTC) (2014)

> 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.

## 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

## 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 use it

Choose BC7 for high-quality desktop colour and ASTC where mobile support is needed or flexible bitrates help. Prefer [Basis Universal / KTX2 supercompression](https://texelatlas.vercel.app/t/basis-universal-ktx2.md) when one file must transcode to whichever format the device supports. Prefer uncompressed or lossless only for lookup tables and tiny UI.

## Cost

cheap — Decoding is free in hardware; encoding is the offline cost.
Measured GPU Weight: 18.14× baseline (moderate) — 0.5623 ms median / 0.5796 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 15.28× baseline (moderate) — 0.243 ms median (2.31× faster on L4).
Ampere A100 scaling: 11.72× baseline (moderate) — 0.3375 ms median (1.67× faster on A100).

## Failure modes

- 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

## Engine support

- babylonjs: builtin — `KTX2 / DDS compressed texture loaders (BCn/ASTC/ETC2 via KhronosTextureContainer2)` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/Misc/khronosTextureContainer2.ts, checked 2026-12-01)
- godot: builtin — `Project import: Compress > Mode = VRAM Compressed (BPTC/S3TC/ETC2/ASTC); Image.compress()` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Image.xml, checked 2026-12-01)
- metal: builtin — `MTLPixelFormat.bc7_rgbaUnorm (macOS) / .astc_4x4_ldr (Apple GPUs)` (evidence: https://developer.apple.com/tutorials/data/documentation/metal/mtlpixelformat.json, checked 2026-12-01) — ASTC on Apple silicon, BC on Mac GPUs; ETC2 also listed.
- threejs: builtin — `new THREE.CompressedTexture(...) with RGBA_ASTC_4x4_Format / RGBA_BPTC_Format` (evidence: https://github.com/mrdoob/three.js/blob/r187/src/constants.js, checked 2026-12-01) — Transcode via KTX2Loader.
- unity: builtin — `Texture Import Settings > Compression / Format (BC7, ASTC)` (evidence: https://docs.unity3d.com/6000.0/Documentation/Manual/texture-choose-format-by-platform.html, checked 2026-12-01) — Platform-dependent texture compression at import.
- unreal: builtin — `Texture Editor > Compression > Compression Settings (TC_Default DXT1/DXT5, TC_BC7, TC_Normalmap, platform ASTC/ETC2)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/python-api/class/TextureCompressionSettings, checked 2026-12-01)
- webgpu: builtin — `requiredFeatures: ['texture-compression-bc'] or ['texture-compression-astc']; formats bc7-rgba-unorm, astc-4x4-unorm` (evidence: https://www.w3.org/TR/webgpu/, checked 2026-12-01) — BC, ASTC and ETC2 are optional device features; availability varies by GPU.

## Dataflow

- Inputs: texture
- Outputs: texture
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal

## Presets

### Block Texture Compression (BC7/ASTC) — 4x4 endpoint quantization & partitions (left) vs uncompressed (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_BLOCK_PX": 10,
  "P_PARTITIONS": 1,
  "P_ERROR_VIS": 0,
  "P_SPLIT": 0.5
}
```

```glsl
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.

## Lineage

- extended by [Basis Universal / KTX2 supercompression](https://texelatlas.vercel.app/t/basis-universal-ktx2.md)

## Combines with

- [Basis Universal / KTX2 supercompression](https://texelatlas.vercel.app/t/basis-universal-ktx2.md): Supercompressed KTX2 transcodes at load time into BC7 or ASTC for the device.

## Combination ideas

- [Block-compressed tile streaming inside a hardware-filtered virtual texture cache](https://texelatlas.vercel.app/ideas/block-compressed-virtual-texture-cache/)

## Sources

1. [primary] (2014) Adaptive Scalable Texture Compression. GPU Pro 5. https://doi.org/10.1201/b16721-26 (verified via crossref on 2026-11-29)
2. [implementation] ARM-software (2015) ARM-software/astc-encoder. https://github.com/ARM-software/astc-encoder License: Apache-2.0. (verified via github on 2026-11-29)
3. [implementation] richgel999 (2021) richgel999/bc7enc_rdo. https://github.com/richgel999/bc7enc_rdo License: NOASSERTION. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Block texture compression (BC7 / ASTC)." https://texelatlas.vercel.app/t/block-texture-compression/ (accessed 2026-12-01).
