{
 "id": "triplanar-mapping",
 "title": "Triplanar mapping",
 "aliases": [],
 "domain": "materials",
 "subdomain": "texture projection",
 "stage": "material",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal",
  "godot",
  "blender"
 ],
 "year_introduced": 2007,
 "inputs": [
  "texture",
  "normals",
  "mesh"
 ],
 "outputs": [
  "texture",
  "material-params"
 ],
 "style": "both",
 "dynamic": "both",
 "summary": "Texturing without UVs: sample a texture along the three world axes and blend by the surface normal. The standard fix for terrain cliffs, procedural meshes and anything where UV stretching is unavoidable.",
 "how_it_works": "Project the world position onto the three axis-aligned planes (yz, xz, xy) to form three UV sets and fetch the texture three times. Blend weights come from the absolute normal raised to a sharpness power and renormalised, w = |n|^k / sum |n|^k, so each projection dominates where it faces the surface. Normal maps need care: each projection's tangent-space normal has to be swizzled into world space (the whiteout or reoriented normal blend methods handle this properly) before blending. Vertex or splat-weighted material masks can pick different textures per layer. Because there are no UVs, the technique works on SDF-meshed, voxel and heightfield terrain, and the cost is three fetches per texture rather than one.",
 "when_to_use": "Choose it for terrain, rocks, procedurally generated meshes and any mesh without good UVs. Prefer UV mapping with an atlas when UVs exist and detail must be authored. Use `histogram-preserving-blending` or `hex-tiling` on top to break repetition visible on large triplanar surfaces. Use `surface-gradient-bump-mapping` to blend normals robustly.",
 "cost": {
  "class": "cheap",
  "notes": "Three texture fetches per map instead of one; bandwidth multiplies with layer count."
 },
 "failure_modes": [
  "Visible blending seams and doubled detail where two projections overlap on 45-degree slopes",
  "Naive normal blending produces wrong lighting; swizzle or use reoriented normal mapping",
  "Texture repeats visibly over large areas without anti-tiling",
  "Texture scale follows world space, so scaled objects show stretched or varying texel density"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-1-generating-complex-procedural-terrains-using-gpu",
   "type": "web",
   "title": "Generating Complex Procedural Terrains Using the GPU",
   "authors": [
    "Ryan Geiss"
   ],
   "year": null,
   "venue": "developer.nvidia.com",
   "url": "https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-1-generating-complex-procedural-terrains-using-gpu",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261118103311/https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-1-generating-complex-procedural-terrains-using-gpu",
     "timestamp": "20261118103311"
    },
    "page_title": "Chapter 1. Generating Complex Procedural Terrains Using the GPU",
    "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-i-geometry/chapter-1-generating-complex-procedural-terrains-using-gpu → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://developer.nvidia.com/gpugems/gpugems3/part-i-geometry/chapter-1-generating-complex-procedural-terrains-using-gpu → 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-i-geometry/chapter-1-generating-complex-procedural-terrains-using-gpu → 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": "geissgenerating"
  }
 ],
 "presets": [
  {
   "id": "triplanar-mapping-specimen",
   "title": "Planar projection (left) vs triplanar projection (right)",
   "runtime": "glsl-fragment",
   "params": {
    "SCALE": 3,
    "SHARPNESS": 4
   },
   "code": "// Texturing without UVs. Left sphere: a single planar projection along z stretches the texture toward the\n// silhouette. Right sphere: triplanar projection blends three axis-aligned lookups by |normal|^4.\nconst float SCALE = 3.0;\nconst float SHARPNESS = 4.0;\n\nvec3 tex(vec2 uv) {\n  vec2 f = fract(uv);\n  vec3 c = mix(vec3(0.9, 0.55, 0.2), vec3(0.2, 0.3, 0.55), mod(floor(uv.x) + floor(uv.y), 2.0));\n  return mix(c, vec3(1.0), smoothstep(0.03, 0.0, abs(length(f - 0.5) - 0.3)));\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, 0.0, 4.0), rd = normalize(vec3(uv, -2.3));\n  vec3 col = vec3(0.08) + 0.06 * uv.y;\n  mat3 rot = mat3(0.87, 0.0, -0.5, 0.0, 1.0, 0.0, 0.5, 0.0, 0.87);\n  for (int i = 0; i < 2; i++) {\n    vec3 c = vec3(i == 0 ? -0.5 : 0.5, 0.0, 0.0);\n    vec3 oc = ro - c; float b = dot(oc, rd); float h = b * b - dot(oc, oc) + 0.46 * 0.46;\n    if (h < 0.0) continue;\n    vec3 n = normalize(ro + rd * (-b - sqrt(h)) - c);\n    vec3 q = rot * n * 0.46;\n    vec3 alb;\n    if (i == 0) alb = tex(q.xy * SCALE * 2.2);\n    else {\n      vec3 w = pow(abs(rot * n), vec3(SHARPNESS)); w /= w.x + w.y + w.z;\n      alb = tex(q.yz * SCALE * 2.2) * w.x + tex(q.zx * SCALE * 2.2) * w.y + tex(q.xy * SCALE * 2.2) * w.z;\n    }\n    col = alb * (0.2 + 0.9 * max(dot(n, normalize(vec3(0.5, 0.6, 0.7))), 0.0));\n  }\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": "triplanar-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.4183,
      "std": 0.1615,
      "unique_colors": 525
     },
     "image": "/specimens/triplanar-mapping-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "hex-tiling",
  "histogram-preserving-blending",
  "surface-gradient-bump-mapping",
  "normal-mapping-mikktspace"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "hex-tiling",
   "why": "Hex-tiling breaks the repetition of each triplanar projection."
  }
 ],
 "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/triplanar-mapping.json"
 },
 "solves": [
  "textures stretch on cliffs and steep terrain",
  "procedural meshes have no uvs",
  "need to texture rocks without unwrapping",
  "uv stretching ruins terrain slopes"
 ],
 "authority": "Geiss",
 "url": "https://texelatlas.vercel.app/t/triplanar-mapping/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 1.29,
  "tier": "feather",
  "p50_ms": 0.0423,
  "p95_ms": 0.0439,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "triplanar-mapping-specimen",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 1.19,
   "tier": "feather",
   "p50_ms": 0.0189,
   "p95_ms": 0.0192,
   "speedup_x": 2.24,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 1.03,
   "tier": "feather",
   "p50_ms": 0.0297,
   "p95_ms": 0.0298,
   "speedup_x": 1.42,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}