{
 "id": "relief-mapping",
 "title": "Relief mapping",
 "aliases": [],
 "domain": "materials",
 "subdomain": "displacement illusion",
 "stage": "material",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal",
  "godot"
 ],
 "year_introduced": 2005,
 "inputs": [
  "texture",
  "normals",
  "uv-atlas"
 ],
 "outputs": [
  "texture",
  "normals"
 ],
 "style": "both",
 "dynamic": "both",
 "summary": "Per-pixel ray-height-field intersection using a linear search followed by a binary search, for robust parallax with correct self-occlusion on arbitrary polygonal surfaces, using only height and normal textures.",
 "how_it_works": "Policarpo, Oliveira and Comba intersect the view ray with a tangent-space heightfield by first stepping along the ray in uniform increments (linear search) until the ray first passes below the surface, then refining that interval by binary search for a handful of iterations. This hybrid guarantees a hit within the bracket and sharpens it quickly. The result gives exact-looking self-occlusion, and the recovered position can feed shadow tests, depth writing and silhouette tricks. Unlike the earlier 2000 relief texture mapping, which pre-warped texture images in a 3D warping pass, this version evaluates entirely in the fragment shader on any polygon with tangent frames and needs no pre-warp.",
 "when_to_use": "Choose it when parallax occlusion's single-interval interpolation breaks and you want robust hit finding at moderate cost. Prefer `relaxed-cone-step-mapping` when thin features are missed by linear search or you need a precomputed cone map. Prefer `parallax-occlusion-mapping` for cheaper per-pixel results with fewer iterations.",
 "cost": {
  "class": "medium",
  "notes": "A linear search of 8-32 height fetches plus 5-8 binary refinements per pixel."
 },
 "failure_modes": [
  "Thin features narrower than the linear step are skipped, so thin walls or spikes vanish",
  "Binary search can lock onto the wrong crossing when the ray enters and exits the height field several times",
  "Silhouette remains flat",
  "Large cost at grazing angles; needs adaptive step count"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/1053427.1053453",
   "type": "paper",
   "title": "Real-time relief mapping on arbitrary polygonal surfaces",
   "authors": [
    "Fábio Policarpo",
    "Manuel M. Oliveira",
    "João L. D. Comba"
   ],
   "year": 2005,
   "venue": "Proceedings of the 2005 symposium on Interactive 3D graphics and games",
   "url": "https://doi.org/10.1145/1053427.1053453",
   "ids": {
    "doi": "10.1145/1053427.1053453"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1053427.1053453",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1053427.1053453",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1053427.1053453",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1053427.1053453",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1053427.1053453",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "policarpo2005relief"
  },
  {
   "role": "primary",
   "key": "doi:10.1145/344779.344947",
   "type": "paper",
   "title": "Relief texture mapping",
   "authors": [
    "Manuel M. Oliveira",
    "Gary Bishop",
    "David McAllister"
   ],
   "year": 2000,
   "venue": "Proceedings of the 27th annual conference on Computer graphics and interactive techniques  - SIGGRAPH '00",
   "url": "https://doi.org/10.1145/344779.344947",
   "ids": {
    "doi": "10.1145/344779.344947"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/344779.344947",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/344779.344947",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/344779.344947",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/344779.344947",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/344779.344947",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "oliveira2000relief"
  }
 ],
 "presets": [
  {
   "id": "relief-mapping-specimen",
   "title": "Relief mapping: linear search only (left) vs linear + binary refinement (right)",
   "runtime": "glsl-fragment",
   "params": {
    "DEPTH": 0.16,
    "LINEAR_STEPS": 10,
    "BINARY_STEPS": 7
   },
   "code": "// Relief mapping: linear search along the view ray through a brick heightfield, then binary-search refinement.\n// Left: 10 linear steps only (stair-stepping at grazing angles). Right: same 10 steps + 7 binary refinements.\nconst float DEPTH = 0.16;\nconst int LINEAR_STEPS = 10;\nconst int BINARY_STEPS = 7;\n\nfloat hgt(vec2 uv) {\n  float row = floor(uv.y / 0.5);\n  vec2 c = vec2(fract((uv.x + 0.5 * mod(row, 2.0)) / 1.0), fract(uv.y / 0.5));\n  float e = min(min(c.x, 1.0 - c.x), min(c.y, 1.0 - c.y) * 0.5);\n  return smoothstep(0.02, 0.07, e);\n}\nvec3 brick(vec2 uv) {\n  float row = floor(uv.y / 0.5); float id = floor(uv.x + 0.5 * mod(row, 2.0));\n  float r = fract(sin(dot(vec2(id, row), vec2(12.9898, 78.233))) * 43758.5453);\n  return mix(vec3(0.5, 0.18, 0.12), vec3(0.7, 0.35, 0.2), r);\n}\nvec3 shadeAt(vec2 uv, float t) {\n  float e = 0.01; float h = hgt(uv);\n  vec3 n = normalize(vec3(-(hgt(uv + vec2(e, 0.0)) - h) / e * 0.12, 1.0, -(hgt(uv + vec2(0.0, e)) - h) / e * 0.12));\n  vec3 c = mix(vec3(0.35), brick(uv), h) * (0.2 + 0.9 * max(dot(n, normalize(vec3(0.4, 0.8, 0.4))), 0.0)) * mix(0.45, 1.0, h);\n  return mix(vec3(0.7, 0.78, 0.88), c, exp(-t * 0.03));\n}\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  vec3 ro = vec3(0.0, 1.0, 0.0), rd = normalize(vec3(uv.x, uv.y - 0.32, -1.0));\n  vec3 col = mix(vec3(0.7, 0.78, 0.88), vec3(0.35, 0.55, 0.85), clamp(rd.y * 3.0, 0.0, 1.0));\n  if (rd.y < -0.001) {\n    float t = -ro.y / rd.y; vec2 p0 = (ro + rd * t).xz * 0.9;\n    vec2 dxz = rd.xz / (-rd.y) * DEPTH * 0.9;\n    float lo = 0.0, hi = 1.0; float step0 = 1.0 / float(LINEAR_STEPS);\n    for (int i = 1; i <= LINEAR_STEPS; i++) {\n      float d = float(i) * step0;\n      if (d >= 1.0 - hgt(p0 + dxz * d)) { hi = d; lo = d - step0; break; }\n      lo = d; hi = 1.0;\n    }\n    float dsel = hi;\n    if (fragCoord.x > 0.5 * iResolution.x) {\n      for (int i = 0; i < BINARY_STEPS; i++) {\n        float m = 0.5 * (lo + hi);\n        if (m >= 1.0 - hgt(p0 + dxz * m)) hi = m; else lo = m;\n      }\n      dsel = hi;\n    }\n    col = shadeAt(p0 + dxz * dsel, t);\n  }\n  if (abs(fragCoord.x - 0.5 * iResolution.x) < 1.0) col = vec3(1.0);\n  fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);\n}\n",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "relief-mapping",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-29T15:51:50.471Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6562,
      "std": 0.1241,
      "unique_colors": 274
     },
     "image": "/specimens/relief-mapping-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "parallax-occlusion-mapping",
  "relaxed-cone-step-mapping",
  "normal-mapping-mikktspace"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/materials/relief-mapping.json"
 },
 "solves": [
  "flat texture lacks depth and parallax on surfaces",
  "bump maps fail at steep viewing angles",
  "brick wall should look truly 3d without geometry",
  "parallax effect with correct self occlusion"
 ],
 "authority": "Policarpo et al., 2005",
 "url": "https://texelatlas.vercel.app/t/relief-mapping/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 4.63,
  "tier": "light",
  "p50_ms": 0.1522,
  "p95_ms": 0.1601,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "relief-mapping-specimen",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 3.79,
   "tier": "light",
   "p50_ms": 0.0602,
   "p95_ms": 0.0604,
   "speedup_x": 2.53,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 2.94,
   "tier": "light",
   "p50_ms": 0.0847,
   "p95_ms": 0.0849,
   "speedup_x": 1.8,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}