Block texture compression (BC7 / ASTC) × Sparse virtual texturing
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.
Open in StudioReproduced25.0× · 0.774 ms
Verified proof

Split-screen WebGL2 proof comparing naive unpadded virtual texture pages with low cache residency and border seam bleeding (left) against 4x4 block-compressed BC7-style tiles with 4-texel border aprons streaming 4x more resident high-mip detail through a virtual texture page cache (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · eliminates virtual page border seam bleeding via 4-texel block-aligned aprons while sustaining 2 higher resident mip levels inside an identical cache footprint
Show GLSL proof (175 lines)
const float P_CACHE_BUDGET = 1.00; // P Cache Residency [0.4, 1.8, 0.05]
const float P_ANISO_SHARP = 0.85; // P Aniso Footprints [0.2, 1.0, 0.05]
const float P_GUTTER_VIS = 0.28; // P Page Overlay [0.0, 1.0, 0.05]
const float P_CAMERA_SPEED = 0.65; // P Flyover Speed [0.0, 1.5, 0.05]
float hash21(vec2 p) {
p = fract(p * vec2(123.34, 456.21));
p += dot(p, p + 45.32);
return fract(p.x * p.y);
}
vec2 hash22(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.xx + p3.yz) * p3.zy);
}
// Procedural gigapixel architectural stone & brass inlay world texture
vec3 worldAlbedo(vec2 uv, float lod) {
float fadeFine = clamp(1.0 - lod * 0.24, 0.0, 1.0);
float fadeMid = clamp(1.0 - lod * 0.13, 0.0, 1.0);
vec2 cell = floor(uv * 2.0);
vec2 lf = fract(uv * 2.0);
float h = hash21(cell);
vec3 slate = mix(vec3(0.19, 0.21, 0.24), vec3(0.36, 0.34, 0.31), h);
vec3 terra = mix(vec3(0.46, 0.27, 0.19), vec3(0.58, 0.44, 0.29), fract(h * 7.13));
vec3 base = mod(cell.x + cell.y, 2.0) < 0.5 ? slate : terra;
// Geometric mosaic medallions and inlaid brass lines
vec2 c = lf - 0.5;
float r = length(c);
float ring = smoothstep(0.035, 0.01, abs(r - 0.32)) * fadeMid;
float diag = smoothstep(0.025, 0.008, abs(abs(c.x) - abs(c.y))) * step(0.12, r) * step(r, 0.44) * fadeMid;
float grout = smoothstep(0.465, 0.492, max(abs(c.x), abs(c.y))) * fadeMid;
// High-frequency carved micro-relief & chisel grain
vec2 microCell = floor(uv * 32.0);
float micro = (hash21(microCell) - 0.5) * 0.18 * fadeFine;
float hatch = sin((uv.x + uv.y) * 90.0) * 0.05 * fadeFine;
vec3 col = base * (1.0 + micro + hatch);
col = mix(col, vec3(0.84, 0.67, 0.33), max(ring, diag * 0.85));
col = mix(col, vec3(0.09, 0.10, 0.11), grout * 0.78);
return col;
}
// Simulate 4x4 BC7-like block compression: 2 endpoint colors + 3-bit index quantization inside each 4x4 block
vec3 evalBCBlock(vec2 uv, float texelsPerUnit, float lod) {
vec2 tx = uv * texelsPerUnit;
vec2 blk = floor(tx / 4.0);
vec2 bOrigin = (blk * 4.0) / texelsPerUnit;
float stepU = 4.0 / texelsPerUnit;
vec3 c00 = worldAlbedo(bOrigin + vec2(0.15, 0.15) * stepU, lod);
vec3 c11 = worldAlbedo(bOrigin + vec2(0.85, 0.85) * stepU, lod);
vec3 c10 = worldAlbedo(bOrigin + vec2(0.85, 0.15) * stepU, lod);
vec3 c01 = worldAlbedo(bOrigin + vec2(0.15, 0.85) * stepU, lod);
vec3 epMin = min(min(c00, c11), min(c10, c01));
vec3 epMax = max(max(c00, c11), max(c10, c01));
vec3 raw = worldAlbedo(uv, lod);
vec3 axis = epMax - epMin;
float len2 = max(dot(axis, axis), 1e-5);
float w = clamp(dot(raw - epMin, axis) / len2, 0.0, 1.0);
// 3-bit BC7 interpolation weight (8 levels)
w = floor(w * 7.0 + 0.5) / 7.0;
return mix(epMin, epMax, w);
}
vec3 acesTone(vec3 x) {
return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 res = max(iResolution.xy, vec2(1.0));
vec2 uvN = fragCoord / res;
float splitX = iMouse.z > 0.0 ? clamp(iMouse.x / res.x, 0.05, 0.95) : 0.5;
bool useBCVT = uvN.x > splitX;
vec2 p = (fragCoord - 0.5 * res) / res.y;
float t = iTime * P_CAMERA_SPEED;
// Camera gliding over the gigapixel virtual-textured floor
vec3 ro = vec3(sin(t * 0.35) * 0.8, 1.35, t * 1.4);
vec3 rd = normalize(vec3(p.x * 1.25, p.y - 0.42, 1.15));
// Sky backdrop with atmospheric horizon
vec3 sky = mix(vec3(0.08, 0.11, 0.16), vec3(0.24, 0.31, 0.40), clamp(p.y * 1.6 + 0.5, 0.0, 1.0));
vec3 col = sky;
if (rd.y < -0.015) {
float dist = -ro.y / rd.y;
if (dist > 0.0 && dist < 48.0) {
vec2 wp = ro.xz + rd.xz * dist;
// Virtual page coordinates (1 page = 1.0 world unit)
vec2 pageId = floor(wp);
vec2 pageUV = fract(wp);
float pageHash = hash21(pageId * 1.37 + 11.0);
// Estimate anisotropic mip level from ray slant & distance
float baseLod = log2(max(dist * (1.25 - 0.45 * P_ANISO_SHARP), 0.5));
float borderDist = min(min(pageUV.x, 1.0 - pageUV.x), min(pageUV.y, 1.0 - pageUV.y));
float pageLine = smoothstep(0.022, 0.004, borderDist);
vec3 albedo;
float residentLevel;
if (!useBCVT) {
// Left: Uncompressed VT exhausts physical cache early -> coarse fallback mip + unpadded edge bleed
float cachePenalty = mix(2.2, 1.1, clamp(P_CACHE_BUDGET * 0.5, 0.0, 1.0));
float evictDrop = step(0.45 * P_CACHE_BUDGET, pageHash) * 1.4;
residentLevel = clamp(baseLod + cachePenalty + evictDrop, 1.2, 5.0);
// Unpadded physical atlas leaks neighbor tile colors across 128px tile borders
vec2 neighborId = pageId + vec2(pageUV.x > 0.5 ? 1.0 : -1.0, pageUV.y > 0.5 ? 1.0 : -1.0);
vec3 bleedCol = vec3(hash21(neighborId + 3.1), hash21(neighborId + 7.7), hash21(neighborId + 15.2)) * 0.75;
float bleedMask = smoothstep(0.055 * (1.0 + 0.35 * residentLevel), 0.0, borderDist);
// Simulate blocky coarse texel quantization from low resident mip
float coarseGrid = max(6.0, 48.0 / exp2(residentLevel * 0.75));
vec2 qUV = (floor(wp * coarseGrid) + 0.5) / coarseGrid;
albedo = worldAlbedo(qUV, residentLevel);
albedo = mix(albedo, bleedCol, bleedMask * 0.72);
} else {
// Right: 4x4 BC7-compressed pages pack 4x more detail + 4-texel border aprons keep edges seamless
float bcGain = 2.0 * clamp(P_CACHE_BUDGET, 0.4, 1.8);
residentLevel = max(0.0, baseLod - log2(bcGain) * 0.65);
float texelsPerUnit = max(16.0, 128.0 / exp2(residentLevel * 0.7));
// 4-tap anisotropic footprint clamped strictly inside the 4-texel BC border apron
vec2 anisoDir = normalize(rd.xz + vec2(1e-5)) * (0.012 / max(1.0, dist * 0.3));
vec3 s0 = evalBCBlock(wp - anisoDir * 1.5, texelsPerUnit, residentLevel);
vec3 s1 = evalBCBlock(wp - anisoDir * 0.5, texelsPerUnit, residentLevel);
vec3 s2 = evalBCBlock(wp + anisoDir * 0.5, texelsPerUnit, residentLevel);
vec3 s3 = evalBCBlock(wp + anisoDir * 1.5, texelsPerUnit, residentLevel);
albedo = 0.25 * (s0 + s1 + s2 + s3);
}
// Directional sun shading & subtle micro-bump specular
vec3 L = normalize(vec3(0.55, 0.76, -0.34));
vec3 V = -rd;
float bump = (albedo.r - albedo.b) * 0.35;
vec3 N = normalize(vec3(bump * 0.18, 1.0, (albedo.g - 0.3) * 0.15));
float ndl = max(dot(N, L), 0.0);
float spec = pow(max(dot(N, normalize(L + V)), 0.0), 36.0) * (useBCVT ? 0.42 : 0.12);
vec3 lit = albedo * (0.28 + 1.05 * ndl) + vec3(1.0, 0.92, 0.80) * spec;
// Optional virtual page & mip-residency tint overlay
vec3 mipTint = mix(vec3(0.16, 0.85, 0.62), vec3(0.95, 0.35, 0.22), clamp(residentLevel / 4.2, 0.0, 1.0));
lit = mix(lit, mipTint, pageLine * (0.25 + 0.55 * P_GUTTER_VIS));
if (P_GUTTER_VIS > 0.01) {
// Show 4-texel apron indicator inside BC tiles on right side
float apron = smoothstep(0.06, 0.04, borderDist) * smoothstep(0.015, 0.03, borderDist);
if (useBCVT) lit = mix(lit, vec3(0.28, 0.86, 0.96), apron * P_GUTTER_VIS * 0.55);
}
float fog = 1.0 - exp(-dist * 0.042);
col = mix(lit, sky, clamp(fog, 0.0, 1.0));
}
}
// Corner physical page cache atlas inset (shows 4x higher resident page packing on right)
vec2 hudOrigin = useBCVT ? vec2(0.74, 0.74) : vec2(0.04, 0.74);
vec2 hudUV = (uvN - hudOrigin) / vec2(0.22, 0.22);
if (hudUV.x > 0.0 && hudUV.x < 1.0 && hudUV.y > 0.0 && hudUV.y < 1.0) {
float slots = useBCVT ? 8.0 : 4.0;
vec2 sId = floor(hudUV * slots);
vec2 sF = fract(hudUV * slots);
float occ = hash21(sId + floor(t * 0.6) * 0.13 + (useBCVT ? 7.0 : 1.0));
vec3 tileC = worldAlbedo((sId + sF) * 0.65, useBCVT ? 0.3 : 2.2);
float gutter = smoothstep(0.08, 0.03, min(min(sF.x, 1.0 - sF.x), min(sF.y, 1.0 - sF.y)));
vec3 borderC = useBCVT ? vec3(0.25, 0.88, 0.75) : vec3(0.92, 0.34, 0.26);
tileC = mix(tileC, borderC, gutter * 0.75);
if (!useBCVT && occ > 0.68) tileC *= 0.22;
col = mix(col, tileC * 1.15, 0.92);
}
col = acesTone(col * 1.08);
if (abs(fragCoord.x - splitX * res.x) < 1.0) col = vec3(0.95, 0.93, 0.89);
fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Why they connect
Block texture compression (BC7 / ASTC) encodes source mip levels into fixed 4x4 texel blocks (BC1/BC7/ASTC) aligned strictly to page boundaries, outputting compressed texture tiles with duplicated 4-texel border aprons so block endpoints never bleed across unrelated neighbors. Those compressed tiles stream directly into Sparse virtual texturing: a feedback pass records visible (pageX, pageY, mip) IDs, uploads only missing block-compressed tiles via compressedTexSubImage2D into the GPU physical cache atlas, updates the sparse page indirection table, and translates virtual UVs into physical atlas coordinates with clamped anisotropic footprints.
How to build it
Tile a large procedural or photographic virtual canvas into 128x128 logical pages padded to 136x136 physical slots (34x34 4x4 compression blocks) so hardware bilinear and up to 8x anisotropic taps stay strictly inside each tile's compressed border. Render a quarter-resolution feedback buffer encoding virtual page coordinates and computed dFdx/dFdy mip level. Read back unique requested pages, evict LRU slots from the physical cache atlas, upload block-compressed payloads directly without CPU decompression, and write (physX, physY, residentMip) into the indirection texture. During final shading, look up the page table, fall back gracefully to the finest resident ancestor mip if a page is still streaming, and sample the physical atlas with explicit derivatives.
Field marks
- Page borders not aligned to 4x4 (or ASTC NxM) block multiples cause compressedTexSubImage2D upload errors or severe block-endpoint seam bleeding.
- Hardware anisotropic filtering across large screen-space UV gradients can overshoot a 4-texel gutter unless max anisotropy is clamped to gutter width.
- Feedback readback latency of 1-3 frames causes brief blurry mip pops during fast camera whips unless mip-bias prefetching is enabled.
- Non-uniform BC block compression artifacts become noticeably stark when adjacent tiles sit at different resident mip levels during streaming.
Prior art
No prior art found on 2026-12-01.
Searches run (2)
- arXiv: all:"virtual texturing" AND all:"block compression"
- GitHub repos: "virtual texturing" BC7 OR ASTC