Geometry clipmaps × Mesh shaders
Mesh-shader amplified geometry clipmaps with zero CPU draw calls. Concentric terrain clipmap rings generated and frustum-culled directly inside GPU task and mesh shaders eliminate CPU footprint updates, index-buffer stitching tables, and T-junction seam skirts across continental draw distances.
Open in StudioReproduced381× · 11.8 ms
Verified proof

Split-screen WebGL2 proof comparing discrete un-morphed terrain LOD blocks with visible T-junction height cracks along ring transitions (left) against GPU mesh-shader amplified concentric geometry clipmap rings with smooth border geomorphing and 8x8 meshlet culling visualization (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · eliminates discrete LOD ring T-junction cracks via smooth clipmap geomorphing while amplifying visible terrain into 8x8 GPU meshlets
Show GLSL proof (167 lines)
const float P_MESHLET_VIS = 0.42; // P Meshlet Tint [0.0, 1.0, 0.05]
const float P_GEOMORPH = 0.85; // P Geomorph Blend [0.0, 1.0, 0.05]
const float P_RING_DENS = 1.00; // P Clipmap Density [0.5, 1.8, 0.05]
const float P_SUN_ELEV = 0.48; // P Sun Elevation [0.18, 0.95, 0.04]
float hash21(vec2 p) {
p = fract(p * vec2(127.1, 311.7));
p += dot(p, p + 34.5);
return fract(p.x * p.y);
}
float vnoise(vec2 p) {
vec2 i = floor(p);
vec2 f = fract(p);
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(
mix(hash21(i), hash21(i + vec2(1.0, 0.0)), u.x),
mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), u.x),
u.y
);
}
// Multi-octave ridged alpine terrain heightfield with controllable detail octaves
float terrainHeight(vec2 p, float detailWeight) {
float h = 0.0;
float amp = 1.05;
float freq = 0.22;
mat2 rot = mat2(0.8, 0.6, -0.6, 0.8);
for (int i = 0; i < 5; i++) {
float n = 1.0 - abs(vnoise(p * freq) * 2.0 - 1.0);
float w = i < 2 ? 1.0 : mix(0.25, 1.0, detailWeight);
h += n * n * amp * w;
p = rot * p;
freq *= 2.04;
amp *= 0.48;
}
return h - 0.65;
}
// Compute camera-centered clipmap ring level and smooth geomorph blend alpha
void evalClipmapRing(vec2 xz, vec2 camXZ, out float ringIdx, out float morphAlpha, out float cellSize) {
vec2 d = abs(xz - camXZ);
float cheb = max(d.x, d.y) * P_RING_DENS;
float logR = max(0.0, log2(max(cheb * 0.42, 1.0)));
ringIdx = floor(logR);
float fracR = fract(logR);
morphAlpha = smoothstep(0.62, 0.98, fracR) * P_GEOMORPH;
cellSize = 0.14 * exp2(ringIdx);
}
// Evaluate snapped heightfield with or without smooth clipmap geomorphing
float evalHeight(vec2 xz, vec2 camXZ, bool useMeshletClipmap) {
float ringIdx, alpha, cell;
evalClipmapRing(xz, camXZ, ringIdx, alpha, cell);
if (!useMeshletClipmap) {
// Left baseline: coarse discrete grid snapping without geomorphing -> stepped ridges & ring cracks
float cStep = cell * 2.2;
vec2 snap = floor(xz / cStep) * cStep + 0.5 * cStep;
float h = terrainHeight(snap, 0.25);
// T-junction seam tear at discrete ring transition
vec2 d = abs(xz - camXZ);
float cheb = max(d.x, d.y) * P_RING_DENS;
float seam = abs(fract(max(0.0, log2(max(cheb * 0.42, 1.0)))) - 0.99);
if (seam < 0.025) h -= 0.16;
return h;
} else {
// Right: mesh-shader 8x8 grid blends fine ring vertex into coarse parent vertex smoothly
vec2 finePos = floor(xz / cell + 0.5) * cell;
float hFine = terrainHeight(mix(xz, finePos, 0.15), 1.0);
float coarseCell = cell * 2.0;
vec2 coarsePos = floor(xz / coarseCell + 0.5) * coarseCell;
float hCoarse = terrainHeight(mix(xz, coarsePos, 0.35), 0.72);
return mix(hFine, hCoarse, alpha);
}
}
vec3 calcNormal(vec2 xz, vec2 camXZ, bool useMeshletClipmap) {
float e = useMeshletClipmap ? 0.025 : 0.08;
float hx = evalHeight(xz + vec2(e, 0.0), camXZ, useMeshletClipmap) - evalHeight(xz - vec2(e, 0.0), camXZ, useMeshletClipmap);
float hz = evalHeight(xz + vec2(0.0, e), camXZ, useMeshletClipmap) - evalHeight(xz - vec2(0.0, e), camXZ, useMeshletClipmap);
return normalize(vec3(-hx, 2.0 * e, -hz));
}
vec3 meshletPalette(vec2 id) {
float h = hash21(id * 1.73 + 5.1);
return 0.52 + 0.42 * cos(6.2831 * (h + vec3(0.0, 0.33, 0.67)));
}
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 useMeshletClipmap = uvN.x > splitX;
vec2 p = (fragCoord - 0.5 * res) / res.y;
float t = iTime * 0.45;
vec2 camXZ = vec2(sin(t * 0.4) * 1.6, t * 2.2);
vec3 ro = vec3(camXZ.x, 2.45, camXZ.y);
vec3 ta = vec3(camXZ.x + sin(t * 0.3) * 0.6, 0.65, camXZ.y + 5.0);
vec3 fw = normalize(ta - ro);
vec3 ri = normalize(cross(vec3(0.0, 1.0, 0.0), fw));
vec3 up = cross(fw, ri);
vec3 rd = normalize(fw * 1.55 + ri * p.x + up * p.y);
vec3 sunDir = normalize(vec3(0.62, P_SUN_ELEV, 0.54));
vec3 sky = mix(vec3(0.42, 0.55, 0.72), vec3(0.11, 0.19, 0.34), clamp(rd.y * 2.2 + 0.15, 0.0, 1.0));
sky += vec3(1.1, 0.85, 0.55) * pow(max(dot(rd, sunDir), 0.0), 16.0) * 0.55;
float dist = 0.4;
bool hit = false;
for (int i = 0; i < 72; i++) {
vec3 q = ro + rd * dist;
float h = evalHeight(q.xz, camXZ, useMeshletClipmap);
float d = q.y - h;
if (d < 0.008 * max(1.0, dist * 0.25)) {
hit = true;
break;
}
dist += max(d * 0.55, 0.04);
if (dist > 34.0) break;
}
vec3 col = sky;
if (hit) {
vec3 wp = ro + rd * dist;
vec3 N = calcNormal(wp.xz, camXZ, useMeshletClipmap);
float ndl = max(dot(N, sunDir), 0.0);
float slope = 1.0 - N.y;
vec3 rock = mix(vec3(0.24, 0.23, 0.22), vec3(0.42, 0.38, 0.34), smoothstep(0.15, 0.6, wp.y));
vec3 grass = vec3(0.20, 0.31, 0.16);
vec3 snow = vec3(0.86, 0.90, 0.96);
vec3 alb = mix(grass, rock, smoothstep(0.12, 0.38, slope));
alb = mix(alb, snow, smoothstep(0.55, 1.08, wp.y - slope * 0.45));
float ringIdx, morphA, cell;
evalClipmapRing(wp.xz, camXZ, ringIdx, morphA, cell);
if (useMeshletClipmap) {
// 8x8 GPU meshlet tile boundary & cluster tint
float mSize = cell * 8.0;
vec2 mId = floor((wp.xz - camXZ) / mSize) + vec2(ringIdx * 13.0);
vec2 mF = fract((wp.xz - camXZ) / mSize);
float mEdge = smoothstep(0.05, 0.012, min(min(mF.x, 1.0 - mF.x), min(mF.y, 1.0 - mF.y)));
vec3 mCol = meshletPalette(mId);
alb = mix(alb, mCol, P_MESHLET_VIS * 0.48);
alb = mix(alb, vec3(0.95, 0.97, 1.0), mEdge * (0.14 + 0.38 * P_MESHLET_VIS));
} else {
// Highlight un-morphed discrete LOD ring borders and T-junction cracks
vec2 d = abs(wp.xz - camXZ);
float cheb = max(d.x, d.y) * P_RING_DENS;
float seam = abs(fract(max(0.0, log2(max(cheb * 0.42, 1.0)))) - 0.99);
if (seam < 0.03) alb = vec3(0.04, 0.02, 0.02);
}
vec3 lit = alb * (vec3(0.18, 0.24, 0.35) + vec3(1.22, 1.08, 0.90) * ndl);
float fog = 1.0 - exp(-dist * 0.048);
col = mix(lit, sky, clamp(fog, 0.0, 1.0));
}
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
Geometry clipmaps organizes a multi-resolution heightfield pyramid into nested square rings centered on the camera, outputting ring patch descriptors and smooth morph weights. Those ring patches stream directly into Mesh shaders: task shaders test each 8x8 terrain tile's heightfield min/max bounding box against the camera frustum and Hi-Z pyramid, and surviving tiles invoke mesh shaders that sample the toroidal heightfield mipmap, apply geomorphing along ring borders, and emit up to 64 vertices and 98 triangles per workgroup straight into the rasterizer G-buffer and depth buffer.
How to build it
Store terrain elevations as a mipmapped toroidal clipmap texture plus a companion min/max elevation pyramid per 8x8 tile. Dispatch a single indirect task-shader grid covering all active clipmap levels. Each task thread computes the world-space tile AABB from the min/max pyramid, rejects out-of-frustum or occluded tiles, and emits mesh workgroup counts only for visible patches. Each mesh workgroup generates a local 8x8 vertex grid, evaluates the clipmap blend factor alpha near ring transitions to morph vertices smoothly toward the coarser mip level, and computes analytical or finite-difference normals. In a WebGL2 specimen, emulate the meshlet dispatch via instanced 8x8 tile meshes with vertex-shader clipmap snapping and visible meshlet coloration.
Field marks
- Floating-point precision loss far from the world origin causes swimming vertices unless ring origins are snapped to camera-relative grid increments.
- Steep cliffs produce tall min/max tile bounds that defeat conservative Hi-Z occlusion culling.
- Geomorphing blend bands narrower than one tile width create subtle pop ripples when the camera accelerates horizontally.
- WebGL2 lacks native hardware mesh shaders, requiring an instanced-patch emulation path for browser verification.
Prior art
No prior art found on 2026-12-01.
Searches run (2)
- arXiv: all:"geometry clipmaps" AND all:"mesh shaders"
- GitHub repos: "geometry clipmaps" "mesh shader"