{
 "id": "relaxed-cone-step-mapping",
 "title": "Relaxed cone step mapping",
 "aliases": [],
 "domain": "materials",
 "subdomain": "displacement illusion",
 "stage": "material",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal",
  "godot"
 ],
 "year_introduced": 2008,
 "inputs": [
  "texture",
  "normals",
  "uv-atlas"
 ],
 "outputs": [
  "texture",
  "normals"
 ],
 "style": "both",
 "dynamic": "static",
 "summary": "Relief mapping accelerated by a precomputed cone map storing, per texel, how wide a cone of empty space rises above the height field. The ray advances safely by cone distance, then a short binary search finds the hit.",
 "how_it_works": "For every texel of the height map, a preprocess computes a cone with apex at the texel's surface point such that the cone's interior never intersects the height field, and stores its ratio (width over height) in a second channel. At render time the ray steps along the safe distance given by the cone at its current location, instead of fixed increments, so empty space is crossed in a few big steps and near-surface regions in small ones. 'Relaxed' cones are allowed to overlap the surface slightly, which makes them wider and faster; a binary search resolves the hit and the guarantee of no missed features is relaxed to rare tiny errors. The approach avoids the missed-thin-feature artifact of linear-search relief mapping while keeping the iteration count to roughly 15 steps.",
 "when_to_use": "Choose it when thin features, steep walls or grazing views show missed intersections in `relief-mapping`, and you can afford a cone-map generation step. Prefer `parallax-occlusion-mapping` for very low-end targets. For real silhouettes, use displaced geometry.",
 "cost": {
  "class": "medium",
  "notes": "Around 10-20 height fetches per pixel with a precomputed cone texture."
 },
 "failure_modes": [
  "Cone-map precompute for large textures is slow; needs regeneration when height changes, so unsuitable for animated heights",
  "Relaxed cones can very occasionally overshoot thin spikes",
  "Same flat-silhouette limitation as other parallax methods",
  "Tiled textures need cones computed with wrap-around"
 ],
 "sources": [
  {
   "role": "tutorial",
   "key": "url:https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-18-relaxed-cone-stepping-relief-mapping",
   "type": "tutorial",
   "title": "Relaxed Cone Stepping for Relief Mapping",
   "authors": [
    "Fabio Policarpo",
    "Manuel M. Oliveira"
   ],
   "year": null,
   "venue": "developer.nvidia.com",
   "url": "https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-18-relaxed-cone-stepping-relief-mapping",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261107171040/https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-18-relaxed-cone-stepping-relief-mapping",
     "timestamp": "20261107171040"
    },
    "page_title": "Chapter 18. Relaxed Cone Stepping for Relief Mapping",
    "host": "developer.nvidia.com",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-18-relaxed-cone-stepping-relief-mapping → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-18-relaxed-cone-stepping-relief-mapping → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-18-relaxed-cone-stepping-relief-mapping → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 0.95,
   "__bib": "policarporelaxed"
  },
  {
   "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"
  }
 ],
 "presets": [
  {
   "id": "relaxed-cone-step-mapping-live",
   "title": "Relaxed cone step mapping — steep parallax relief & binary search vs flat bump split",
   "runtime": "glsl-fragment",
   "params": {
    "P_RELIEF_DEPTH": 0.18,
    "P_CONE_STEPS": 18,
    "P_SHADOW_SOFT": 0.85,
    "P_SPLIT": 0.34
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_RELIEF_DEPTH = 0.18; // P Relief Depth [0.02, 0.36, 0.01]\nconst float P_CONE_STEPS = 18.0; // P Cone Steps [6.0, 28.0, 1.0]\nconst float P_SHADOW_SOFT = 0.85; // P Self-Shadow [0.0, 1.0, 0.02]\nconst float P_SPLIT = 0.34; // P Flat/RCSM Split [0.0, 1.0, 0.02]\n\nfloat hash21(vec2 p) {\n  p = fract(p * vec2(123.34, 456.21));\n  p += dot(p, p + 45.32);\n  return fract(p.x * p.y);\n}\n\n// High-relief ornamental stonework heightfield in [0, 1] (0 = deep recessed mortar, 1 = raised stone boss)\nfloat sampleHeight(vec2 uv) {\n  vec2 p = uv * 2.6;\n  // Running-bond dressed stone ashlar blocks + carved ornamental medallions\n  float row = floor(p.y);\n  p.x += mod(row, 2.0) * 0.5;\n  vec2 id = floor(p);\n  vec2 f = fract(p) - 0.5;\n\n  float hRand = hash21(id);\n  // Steep chamfered stone block profile (torture test for steep parallax relief!)\n  vec2 b = abs(f) - vec2(0.41, 0.39);\n  float dBlock = length(max(b, 0.0)) + min(max(b.x, b.y), 0.0);\n  float blockH = smoothstep(0.055, -0.055, dBlock) * (0.72 + 0.20 * hRand);\n\n  // Carved circular recessed rosettes & raised brass bosses on alternating blocks\n  float r = length(f);\n  float ring = smoothstep(0.055, 0.01, abs(r - 0.22)) * 0.22 * step(0.45, hRand);\n  float recess = smoothstep(0.20, 0.11, r) * 0.38 * step(0.45, hRand);\n  float boss = smoothstep(0.11, 0.04, r) * 0.44 * step(0.45, hRand);\n\n  // Subtle chiseled stone surface texture\n  float chisel = 0.03 * sin(p.x * 28.0 + hRand * 6.0) * cos(p.y * 24.0);\n  return clamp(blockH + ring - recess + boss + chisel, 0.02, 1.0);\n}\n\nvec3 sampleReliefNormal(vec2 uv, float depth) {\n  float e = 0.004;\n  float hx = sampleHeight(uv + vec2(e, 0.0)) - sampleHeight(uv - vec2(e, 0.0));\n  float hy = sampleHeight(uv + vec2(0.0, e)) - sampleHeight(uv - vec2(0.0, e));\n  return normalize(vec3(-hx * depth * 10.5, -hy * depth * 10.5, 1.0));\n}\n\n// Relaxed Cone Step Mapping: accelerated cone-ratio stepping + 5-step binary refinement\nvec3 relaxedConeMarch(vec2 uv0, vec3 viewTS, float depth, int steps) {\n  // Ray marches in tangent space from height z = 1.0 down toward z = 0.0\n  vec3 ray = vec3(uv0, 1.0);\n  vec3 stepDir = vec3(-viewTS.xy * depth / max(viewTS.z, 0.22), -1.0);\n  float t = 0.0;\n  float prevT = 0.0;\n\n  // Phase 1: Relaxed cone step (takes large safe leaps across empty space above heightfield)\n  float relaxedConeRatio = 0.58;\n  for (int i = 0; i < 28; i++) {\n    if (i >= steps) break;\n    vec3 cur = ray + stepDir * t;\n    float h = sampleHeight(cur.xy);\n    float deltaH = cur.z - h;\n    if (deltaH <= 0.001) break;\n    prevT = t;\n    // Cone step advances proportionally to vertical clearance * cone ratio\n    float dt = max(deltaH * relaxedConeRatio, 0.028);\n    t = min(t + dt, 1.0);\n  }\n\n  // Phase 2: Binary search refinement between [prevT, t] for razor-sharp relief edges\n  float lo = prevT, hi = t;\n  for (int k = 0; k < 5; k++) {\n    float mid = 0.5 * (lo + hi);\n    vec3 cm = ray + stepDir * mid;\n    if (cm.z > sampleHeight(cm.xy)) lo = mid; else hi = mid;\n  }\n  return ray + stepDir * (0.5 * (lo + hi));\n}\n\n// Parallax self-shadowing march from displaced surface point toward tangent-space light\nfloat reliefShadow(vec3 hitPos, vec3 lightTS, float depth) {\n  if (lightTS.z <= 0.05) return 0.0;\n  vec3 stepDir = vec3(lightTS.xy * depth / max(lightTS.z, 0.25), 1.0);\n  float sh = 1.0;\n  float t = 0.05;\n  for (int i = 0; i < 12; i++) {\n    vec3 p = hitPos + stepDir * t;\n    if (p.z >= 1.0) break;\n    float h = sampleHeight(p.xy);\n    float pen = (h - p.z) * 4.5 / (0.25 + t);\n    sh = min(sh, clamp(1.0 - pen, 0.0, 1.0));\n    t += 0.075;\n  }\n  return sh;\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 screenUV = fragCoord / iResolution.xy;\n\n  float depth = clamp(P_RELIEF_DEPTH, 0.01, 0.40);\n  int steps = int(clamp(P_CONE_STEPS, 4.0, 28.0));\n  float shStr = clamp(P_SHADOW_SOFT, 0.0, 1.0);\n  float splitX = clamp(P_SPLIT, 0.0, 1.0);\n\n  // Orbiting oblique camera viewing a tilted relief wall at steep grazing perspective\n  float camAng = 0.35 * sin(iTime * 0.45);\n  vec3 ro = vec3(sin(camAng) * 0.9, -0.78, 1.48);\n  vec3 ta = vec3(0.0, 0.06, 0.0);\n  vec3 ww = normalize(ta - ro);\n  vec3 uu = normalize(cross(ww, vec3(0.0, 0.0, 1.0)));\n  vec3 vv = cross(uu, ww);\n  vec3 rd = normalize(uv.x * uu + uv.y * vv + 1.45 * ww);\n\n  // Intersect base relief plane at z = 0 (tangent space: X=right, Y=up, Z=out of wall)\n  float tPlane = -ro.z / min(rd.z, -0.001);\n  vec3 hitBase = ro + rd * tPlane;\n  vec2 baseUV = hitBase.xy * 0.72 + vec2(iTime * 0.04, 0.0);\n  vec3 viewTS = normalize(-rd);\n\n  bool useRCSM = (screenUV.x >= splitX);\n  vec3 surfHit = useRCSM ? relaxedConeMarch(baseUV, viewTS, depth, steps) : vec3(baseUV, sampleHeight(baseUV));\n  vec2 sUV = surfHit.xy;\n  float hVal = sampleHeight(sUV);\n  vec3 nTS = sampleReliefNormal(sUV, depth);\n\n  // Animated warm torch light grazing across the deep carved masonry\n  vec3 lPos = vec3(0.75 * cos(iTime * 0.65), 0.55 * sin(iTime * 0.52), 0.72);\n  vec3 lDir = normalize(lPos - vec3(hitBase.xy, 0.0));\n\n  float sh = useRCSM ? mix(1.0, reliefShadow(surfHit, lDir, depth), shStr) : 1.0;\n\n  // Material palette: dark basalt mortar, warm carved sandstone ashlar, burnished gold bosses\n  vec3 mortarCol = vec3(0.09, 0.085, 0.095);\n  vec3 stoneCol = mix(vec3(0.32, 0.30, 0.28), vec3(0.58, 0.52, 0.45), smoothstep(0.18, 0.78, hVal));\n  vec3 goldCol = vec3(0.92, 0.70, 0.28);\n  float isGold = smoothstep(0.84, 0.94, hVal);\n  vec3 alb = mix(mortarCol, stoneCol, smoothstep(0.08, 0.28, hVal));\n  alb = mix(alb, goldCol, isGold);\n\n  float ndl = max(dot(nTS, lDir), 0.0);\n  vec3 hVec = normalize(lDir + viewTS);\n  float specPow = mix(18.0, 64.0, isGold);\n  float spec = pow(max(dot(nTS, hVec), 0.0), specPow) * mix(0.25, 1.35, isGold);\n\n  // Crevice cavity AO proportional to relief depth\n  float cavAO = mix(0.28, 1.0, smoothstep(0.05, 0.72, hVal));\n  vec3 col = alb * (vec3(2.2, 1.75, 1.25) * ndl * sh + vec3(0.18, 0.24, 0.36) * cavAO) + vec3(1.0, 0.88, 0.65) * spec * sh;\n\n  if (splitX > 0.01 && splitX < 0.99 && abs(screenUV.x - splitX) < 0.004) {\n    col = vec3(0.35, 0.90, 1.0);\n  }\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "relaxed-cone-step-mapping",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:50:13.852Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.7473,
      "std": 0.2206,
      "unique_colors": 265
     },
     "image": "/specimens/relaxed-cone-step-mapping-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "relief-mapping",
  "parallax-occlusion-mapping",
  "normal-mapping-mikktspace"
 ],
 "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/relaxed-cone-step-mapping.json"
 },
 "solves": [
  "relief mapping misses thin features or steep walls",
  "parallax effect shows holes at grazing angles",
  "need faster safe stepping through a height texture",
  "bumpy brick surface should look deep without geometry",
  "ray-versus-heightfield artefacts on texture detail"
 ],
 "authority": "Policarpo et al., 2005",
 "url": "https://texelatlas.vercel.app/t/relaxed-cone-step-mapping/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 28.82,
  "tier": "heavy",
  "p50_ms": 0.9483,
  "p95_ms": 0.9665,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "relaxed-cone-step-mapping-live",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 23.14,
   "tier": "heavy",
   "p50_ms": 0.368,
   "p95_ms": 0.3698,
   "speedup_x": 2.58,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 19.06,
   "tier": "moderate",
   "p50_ms": 0.5488,
   "p95_ms": 0.5547,
   "speedup_x": 1.73,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}