{
 "id": "parallax-occlusion-mapping",
 "title": "Parallax occlusion mapping",
 "aliases": [],
 "domain": "materials",
 "subdomain": "displacement illusion",
 "stage": "material",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal",
  "godot"
 ],
 "year_introduced": 2006,
 "inputs": [
  "texture",
  "normals",
  "uv-atlas"
 ],
 "outputs": [
  "texture",
  "normals"
 ],
 "style": "both",
 "dynamic": "both",
 "summary": "Per-pixel ray march through a height map in tangent space to shift texture coordinates and produce parallax and self-occlusion on flat polygons. Cheaper than real displacement, convincing on bricks and cobblestones.",
 "how_it_works": "Tatarchuk's method casts the view ray into the tangent-space heightfield beneath the polygon. Starting at the entry point it steps along the ray in a fixed or adaptive number of linear samples (more at grazing angles), comparing the ray height to the sampled height. At the first crossing it linearly interpolates between the last two samples to refine the intersection, then uses the resulting UV for all subsequent texture lookups (albedo, normal, roughness). Optionally a second march toward the light yields soft self-shadowing. LOD blends the effect off with distance, reducing sample counts and eventually falling back to plain normal mapping. It is a purely fragment-shader technique.",
 "when_to_use": "Choose it for floors, walls and rocky ground where parallax and self-occlusion add credibility from a modest viewing range. Prefer `relief-mapping` or `relaxed-cone-step-mapping` for more accurate, artifact-free intersections or steeper heights. Prefer real tessellation or `nanite-virtualized-geometry` when silhouettes must be displaced. Prefer `normal-mapping-mikktspace` when height is subtle.",
 "cost": {
  "class": "medium",
  "notes": "Several height-map fetches per pixel (often 8-32); scales with sample count and screen coverage."
 },
 "failure_modes": [
  "Stair-stepping and swimming at grazing angles when the sample count is too low",
  "Silhouettes and polygon edges stay flat, so the illusion breaks at object borders",
  "Texture distortion and layered sampling artefacts on steep height with few samples",
  "Does not interact with depth buffer unless depth is written, so intersections with other geometry look wrong"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/1111411.1111423",
   "type": "paper",
   "title": "Dynamic parallax occlusion mapping with approximate soft shadows",
   "authors": [
    "Natalya Tatarchuk"
   ],
   "year": 2006,
   "venue": "Proceedings of the 2006 symposium on Interactive 3D graphics and games  - SI3D '06",
   "url": "https://doi.org/10.1145/1111411.1111423",
   "ids": {
    "doi": "10.1145/1111411.1111423"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111423",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111423",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111423",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111423",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/1111411.1111423",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "tatarchuk2006dynamic"
  }
 ],
 "presets": [
  {
   "id": "parallax-occlusion-mapping-specimen",
   "title": "Brick heightfield: flat lookup (left) vs parallax occlusion mapping (right)",
   "runtime": "glsl-fragment",
   "params": {
    "DEPTH": 0.16,
    "LAYERS": 24
   },
   "code": "// Parallax occlusion mapping on a brick heightfield seen at grazing angle.\n// Left: flat texture lookup (no parallax). Right: layered height-field ray march in uv space, with linear\n// interpolation between the last two layers.\nconst float DEPTH = 0.16;\nconst int LAYERS = 24;\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 alb = mix(vec3(0.35), brick(uv), h);\n  vec3 c = alb * (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    if (fragCoord.x < 0.5 * iResolution.x) col = shadeAt(p0, t);\n    else {\n      vec2 dxz = rd.xz / (-rd.y) * DEPTH * 0.9;\n      float dPrev = 0.0, hPrev = 1.0 - hgt(p0), dCur = 0.0; vec2 uvh = p0;\n      for (int i = 1; i <= LAYERS; i++) {\n        float d = float(i) / float(LAYERS);\n        vec2 q = p0 + dxz * d; float sd = 1.0 - hgt(q);\n        if (d >= sd) {\n          float a0 = d - sd, a1 = hPrev - dPrev;\n          float w = a0 / max(a0 - (dPrev - hPrev) , 1e-4);\n          float dd = mix(d, dPrev, clamp(w, 0.0, 1.0)); uvh = p0 + dxz * dd; break;\n        }\n        dPrev = d; hPrev = sd; uvh = q;\n      }\n      col = shadeAt(uvh, t);\n    }\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": "parallax-occlusion-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.6448,
      "std": 0.1374,
      "unique_colors": 285
     },
     "image": "/specimens/parallax-occlusion-mapping-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "relief-mapping",
  "relaxed-cone-step-mapping",
  "normal-mapping-mikktspace",
  "nanite-virtualized-geometry"
 ],
 "extends": [
  "relief-mapping"
 ],
 "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/parallax-occlusion-mapping.json"
 },
 "solves": [
  "flat bricks or cobblestones look like a painted wall",
  "normal maps lack depth and parallax",
  "want self-occlusion on surfaces without extra geometry",
  "floors need depth shift when camera moves"
 ],
 "authority": "Tatarchuk, 2006",
 "url": "https://texelatlas.vercel.app/t/parallax-occlusion-mapping/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 3.55,
  "tier": "light",
  "p50_ms": 0.1168,
  "p95_ms": 0.1233,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "parallax-occlusion-mapping-specimen",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 2.67,
   "tier": "light",
   "p50_ms": 0.0425,
   "p95_ms": 0.0429,
   "speedup_x": 2.75,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 2.24,
   "tier": "light",
   "p50_ms": 0.0644,
   "p95_ms": 0.0645,
   "speedup_x": 1.81,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}