{
 "id": "geometry-images",
 "title": "Geometry Images",
 "aliases": [],
 "domain": "geometry",
 "subdomain": "surface parametrization",
 "stage": "geometry",
 "realtime": "interactive",
 "platforms": [
  "cpu",
  "webgl2",
  "webgpu",
  "desktop-gpu"
 ],
 "year_introduced": 2002,
 "inputs": [
  "mesh"
 ],
 "outputs": [
  "texture",
  "uv-atlas"
 ],
 "style": "both",
 "dynamic": "static",
 "summary": "Cuts a mesh into a single disc, parametrizes it onto a square, and stores x, y, z as three colour channels of an ordinary image. The geometry becomes a texture that GPUs filter, compress and tessellate naturally.",
 "how_it_works": "Choose a cut graph that turns the surface into a topological disc, e.g. by shortest paths between handles after removing triangles until only a tree remains. Parametrize the disc onto a square so that the boundary maps to the border with matching sample points on the two sides of every seam. Then resample the surface on a regular grid in parameter space and store positions in a floating-point image, along with normals in a second one. The grid structure gives a mesh implicitly (connect neighbours), with no index buffer. Because the seams are consistent, 'zippering' the border samples makes the surface watertight. Standard image tools apply: mipmaps give levels of detail, compression gives mesh compression, and displacement-map-like editing works on the geometry directly.",
 "when_to_use": "Choose it for regular, GPU-friendly meshes: LOD via mipmaps, streaming, compression research and neural surface representations that need a regular grid. Prefer `xatlas` or `lscm-uv-unwrapping` when you want a conventional UV atlas for texturing a retained mesh, and `qem-mesh-simplification` for LODs of an irregular mesh.",
 "cost": {
  "class": "interactive",
  "notes": "Parametrization and resampling are offline; rendering is a regular grid draw call."
 },
 "failure_modes": [
  "Seam artifacts and cracks where mip levels or filtering break the boundary correspondence",
  "Stretching in the parameter domain undersamples regions of high detail",
  "Single-chart parametrization of high-genus shapes is hard and distorts heavily",
  "Bilinear filtering of positions mixes across seams unless borders are handled"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/566570.566589",
   "type": "paper",
   "title": "Geometry images",
   "authors": [
    "Xianfeng Gu",
    "Steven J. Gortler",
    "Hugues Hoppe"
   ],
   "year": 2002,
   "venue": "Proceedings of the 29th annual conference on Computer graphics and interactive techniques",
   "url": "https://doi.org/10.1145/566570.566589",
   "ids": {
    "doi": "10.1145/566570.566589"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/566570.566589",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/566570.566589",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/566570.566589",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/566570.566589",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/566570.566589",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "gu2002geometry"
  }
 ],
 "presets": [
  {
   "id": "geometry-images-live",
   "title": "Geometry Images — 2D square RGB=[X,Y,Z] atlas (left) vs reconstructed 3D surface & cut seam (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_GRID_RES": 12,
    "P_SEAM_VIS": 1,
    "P_ROT_SPEED": 0.75,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_GRID_RES = 12.0; // P Regular Grid N [6.0, 24.0, 2.0]\nconst float P_SEAM_VIS = 1.0; // P Cut Seam Highlight [0.0, 1.5, 0.05]\nconst float P_ROT_SPEED = 0.75; // P Spin Speed [0.0, 2.2, 0.05]\nconst float P_SPLIT = 0.48; // P 2D Atlas / 3D Mesh [0.0, 1.0, 0.02]\n\nmat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }\n\n// Octahedral geometry-image bijection: 2D square [0,1]^2 <-> 3D unit sphere S^2 (Gu-Gortler-Hoppe!)\nvec3 octDecode(vec2 uv01) {\n  vec2 f = uv01 * 2.0 - 1.0;\n  vec3 n = vec3(f.x, f.y, 1.0 - abs(f.x) - abs(f.y));\n  float t = max(-n.z, 0.0);\n  n.x += (n.x >= 0.0) ? -t : t;\n  n.y += (n.y >= 0.0) ? -t : t;\n  return normalize(n);\n}\n\nvec2 octEncode(vec3 n) {\n  n /= max(abs(n.x) + abs(n.y) + abs(n.z), 1e-5);\n  if (n.z < 0.0) {\n    vec2 sgn = vec2((n.x >= 0.0) ? 1.0 : -1.0, (n.y >= 0.0) ? 1.0 : -1.0);\n    n.xy = (1.0 - abs(n.yx)) * sgn;\n  }\n  return n.xy * 0.5 + 0.5;\n}\n\n// Sculpted genus-0 organic displacement encoded into the Geometry Image RGB = (x, y, z)\nvec3 evalSurfacePoint(vec3 dir) {\n  float disp = 0.68 + 0.14 * sin(dir.x * 4.2) * cos(dir.y * 4.2) + 0.09 * sin(dir.z * 5.5);\n  return dir * disp;\n}\n\nfloat mapShape(vec3 p, float spin) {\n  vec3 q = p;\n  q.xz = rot2(spin * 0.65) * q.xz;\n  q.yz = rot2(0.35) * q.yz;\n  float r = length(q);\n  vec3 d = q / max(r, 1e-5);\n  float targetR = length(evalSurfacePoint(d));\n  return (r - targetR) * 0.72;\n}\n\nvec3 calcNormal(vec3 p, float spin) {\n  vec2 e = vec2(0.0022, 0.0);\n  return normalize(vec3(\n    mapShape(p + e.xyy, spin) - mapShape(p - e.xyy, spin),\n    mapShape(p + e.yxy, spin) - mapShape(p - e.yxy, spin),\n    mapShape(p + e.yyx, spin) - mapShape(p - e.yyx, spin)\n  ));\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  vec2 uv01 = fragCoord / max(iResolution.xy, vec2(1.0));\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  bool is3D = uv01.x >= split;\n  float gridN = clamp(floor(P_GRID_RES + 0.5), 6.0, 26.0);\n  float seamVis = clamp(P_SEAM_VIS, 0.0, 1.5);\n  float spin = iTime * max(P_ROT_SPEED, 0.0);\n\n  vec3 col = mix(vec3(0.026, 0.036, 0.058), vec3(0.068, 0.088, 0.138), smoothstep(-0.55, 0.55, uv.y));\n\n  if (!is3D) {\n    // Left: 2D square Geometry Image texture where RGB encodes 3D vertex positions (x, y, z)\n    float panelCX = split * 0.5 * (iResolution.x / max(iResolution.y, 1.0));\n    vec2 rel = vec2((uv01.x - split * 0.5) * (iResolution.x / max(iResolution.y, 1.0)), uv.y);\n    vec2 gUV = rel / 0.72 + 0.5;\n\n    if (gUV.x >= 0.0 && gUV.x <= 1.0 && gUV.y >= 0.0 && gUV.y <= 1.0) {\n      vec3 dir = octDecode(gUV);\n      vec3 pos3D = evalSurfacePoint(dir);\n      // Map XYZ coordinates [-0.9, 0.9] -> [0, 1] RGB channels (exact Geometry Image encoding)\n      vec3 rgbPos = clamp(pos3D * 0.55 + 0.5, 0.0, 1.0);\n\n      // Regular 2D square sampling lattice (completely regular topology!)\n      vec2 gf = abs(fract(gUV * gridN - 0.5) - 0.5);\n      float gWire = smoothstep(0.055, 0.012, min(gf.x, gf.y));\n      col = mix(rgbPos, vec3(0.04, 0.06, 0.10), gWire * 0.52);\n\n      // Outer cut-seam boundary (the 4 edges of the square glue symmetrically onto the 3D cut tree!)\n      float bdr = min(min(gUV.x, 1.0 - gUV.x), min(gUV.y, 1.0 - gUV.y));\n      col = mix(col, vec3(1.0, 0.88, 0.28), smoothstep(0.024, 0.005, bdr) * min(seamVis, 1.0));\n    }\n  } else {\n    // Right: Reconstructed 3D surface sampled from the regular 2D Geometry Image grid\n    vec2 rightUV = vec2((uv01.x - (split + 1.0) * 0.5) * (iResolution.x / max(iResolution.y, 1.0)), uv.y);\n    vec3 ro = vec3(0.0, 0.04, 2.38);\n    vec3 rd = normalize(vec3(rightUV, -1.52));\n\n    float t = 0.0;\n    bool hit = false;\n    for (int i = 0; i < 64; i++) {\n      float d = mapShape(ro + rd * t, spin);\n      if (d < 0.002) { hit = true; break; }\n      t += d;\n      if (t > 7.0) break;\n    }\n\n    if (hit) {\n      vec3 p = ro + rd * t;\n      vec3 n = calcNormal(p, spin);\n\n      vec3 objP = p;\n      objP.xz = rot2(spin * 0.65) * objP.xz;\n      objP.yz = rot2(0.35) * objP.yz;\n      vec2 gUV = octEncode(normalize(objP));\n\n      // Regular quad mesh reconstructed directly from the 2D Geometry Image pixels\n      vec2 gf = abs(fract(gUV * gridN - 0.5) - 0.5);\n      float gWire = smoothstep(0.060, 0.014, min(gf.x, gf.y));\n      // Highlight the 3D cut seam (where gUV hits 0 or 1 boundary of the square)\n      float bdr = min(min(gUV.x, 1.0 - gUV.x), min(gUV.y, 1.0 - gUV.y));\n      float seamLine = smoothstep(0.025, 0.005, bdr);\n\n      vec3 l1 = normalize(vec3(0.58, 0.82, 0.55));\n      float diff = max(dot(n, l1), 0.0);\n      float spec = pow(max(dot(n, normalize(l1 - rd)), 0.0), 42.0);\n      vec3 rgbPos = clamp(objP * 0.55 + 0.5, 0.0, 1.0);\n      vec3 alb = mix(vec3(0.76, 0.80, 0.86), rgbPos, 0.62);\n\n      col = alb * (0.28 + 0.82 * diff) + vec3(0.95) * spec * 0.45;\n      col = mix(col, vec3(0.04, 0.07, 0.12), gWire * 0.55);\n      col = mix(col, vec3(1.0, 0.88, 0.28), seamLine * 0.92 * min(seamVis, 1.2));\n    }\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(uv01.x - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "geometry-images",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T19:53:27.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6326,
      "std": 0.208,
      "min": 0.1895,
      "max": 0.919
     },
     "image": "/specimens/geometry-images-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "xatlas",
  "lscm-uv-unwrapping",
  "qem-mesh-simplification"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "lscm-uv-unwrapping",
   "why": "A conformal or stretch-minimising parametrization places the chart on the square."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/geometry/geometry-images.json"
 },
 "solves": [
  "want mesh geometry stored as a regular texture",
  "need lod through mipmaps on geometry",
  "neural surface needs a regular grid representation",
  "stream and compress meshes like ordinary images"
 ],
 "authority": "Gu et al., 2002",
 "url": "https://texelatlas.vercel.app/t/geometry-images/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 13.87,
  "tier": "moderate",
  "p50_ms": 0.43,
  "p95_ms": 0.4543,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 36,
  "preset_id": "geometry-images-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 10.1,
   "tier": "moderate",
   "p50_ms": 0.1606,
   "p95_ms": 0.167,
   "speedup_x": 2.68,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 8.1,
   "tier": "moderate",
   "p50_ms": 0.2333,
   "p95_ms": 0.2483,
   "speedup_x": 1.84,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}