{
 "id": "path-tracing",
 "title": "Unidirectional Path Tracing",
 "aliases": [
  "PT",
  "Monte Carlo path tracing",
  "Kajiya path tracing"
 ],
 "domain": "gi",
 "subdomain": "Monte Carlo light transport",
 "stage": "lighting",
 "realtime": "offline",
 "platforms": [
  "cpu",
  "cuda",
  "desktop-gpu",
  "webgpu",
  "webgl2",
  "blender"
 ],
 "year_introduced": 1986,
 "inputs": [
  "mesh",
  "material-params",
  "hdr-image"
 ],
 "outputs": [
  "radiance"
 ],
 "style": "photoreal",
 "dynamic": "both",
 "summary": "Estimates the rendering equation by tracing random walks from the camera, sampling a BSDF direction at each hit and gathering emission. Unbiased and general, but noisy until many samples per pixel accumulate.",
 "how_it_works": "Light leaving a point is emission plus the integral of incoming light weighted by the BSDF and cosine. Path tracing evaluates that recursive integral with a random walk. From the camera you shoot a ray, find the hit, and add any emitted light. You then sample one outgoing direction from the BSDF, multiply the running **throughput** by `f * cos / pdf`, and continue. Each pixel averages many such walks.\n\nTwo additions make it practical. **Next-event estimation** also connects every hit to a point on a light source with a shadow ray, which is why small lights become tractable. It is normally combined with BSDF sampling through multiple importance sampling. **Russian roulette** ends long walks at random and divides survivors' throughput by the survival probability, which keeps the estimator unbiased while bounding cost.\n\nBecause every bounce is sampled from the true scene, caustics, color bleeding, glossy interreflection and soft shadows all emerge without special cases. The price is variance: error falls with the square root of the sample count.",
 "when_to_use": "Choose it as the ground truth reference and as the default offline integrator: it is simple, unbiased and handles any BSDF and geometry you can intersect. In real time it is the base that [restir-di](restir-di) / [restir-gi](restir-gi) resampling and denoisers are built on.\n\nPrefer [bidirectional-path-tracing](bidirectional-path-tracing) or [vertex-connection-and-merging](vertex-connection-and-merging) when light mostly arrives through small openings or specular chains (caustics, lamps behind glass). Prefer [photon-mapping](photon-mapping) for caustics at low cost. Prefer [path-guiding](path-guiding) when plain sampling is too noisy on hard indirect paths. Prefer [ddgi](ddgi) or [lumen-gi](lumen-gi) when you need a few milliseconds per frame rather than converged images.",
 "cost": {
  "class": "offline",
  "notes": "Cost scales with samples per pixel times path length times ray cost. Real-time use is limited to one or two samples per pixel plus denoising, which is hardware-ray-tracing territory."
 },
 "failure_modes": [
  "Fireflies: rare high-contrast paths (a diffuse bounce hitting a tiny bright light, or a specular-diffuse-specular chain) produce isolated bright pixels that clamping only hides at the cost of bias",
  "Caustics seen through glass or reflected by mirrors converge extremely slowly, since the camera walk must hit a small light by chance",
  "Low-sample output is high-frequency noise, so real-time use depends on denoisers that smear detail and ghost on motion",
  "Light leaking and energy loss from sloppy Russian roulette or clamped throughput if the pdf and BSDF are mismatched"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/15922.15902",
   "type": "paper",
   "title": "The rendering equation",
   "authors": [
    "James T. Kajiya"
   ],
   "year": 1986,
   "venue": "Proceedings of the 13th annual conference on Computer graphics and interactive techniques",
   "url": "https://doi.org/10.1145/15922.15902",
   "ids": {
    "doi": "10.1145/15922.15902"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/15922.15902",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/15922.15902",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/15922.15902",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/15922.15902",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/15922.15902",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "kajiya1986rendering"
  },
  {
   "role": "tutorial",
   "key": "url:https://pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Path_Tracing",
   "type": "tutorial",
   "title": "Path Tracing (Physically Based Rendering, 3rd edition)",
   "authors": [
    "Matt Pharr",
    "Wenzel Jakob",
    "Greg Humphreys"
   ],
   "year": null,
   "venue": "pbr-book.org",
   "url": "https://pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Path_Tracing",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261022120625/https://www.pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Path_Tracing",
     "timestamp": "20261022120625"
    },
    "page_title": "Path Tracing",
    "host": "pbr-book.org",
    "title_confirmed_by_page": false,
    "title_unconfirmed": true
   },
   "provenance": {
    "title": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Path_Tracing → 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://pbr-book.org/3ed-2018/Light_Transport_I_Surface_Reflection/Path_Tracing → 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.4444444444444444,
   "__bib": "pharrpath"
  },
  {
   "role": "implementation",
   "key": "gh:gkjohnson/three-gpu-pathtracer",
   "type": "code",
   "title": "gkjohnson/three-gpu-pathtracer",
   "description": "Path tracing renderer and utilities for three.js built on top of three-mesh-bvh.",
   "authors": [
    "gkjohnson"
   ],
   "year": 2021,
   "venue": "GitHub",
   "url": "https://github.com/gkjohnson/three-gpu-pathtracer",
   "ids": {
    "repo": "gkjohnson/three-gpu-pathtracer"
   },
   "license": "MIT",
   "extra": {
    "stars": 2080,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-29T07:51:13Z",
    "language": "JavaScript",
    "homepage": "https://gkjohnson.github.io/three-gpu-pathtracer/index.html",
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gkjohnson/three-gpu-pathtracer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gkjohnson/three-gpu-pathtracer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gkjohnson/three-gpu-pathtracer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gkjohnson/three-gpu-pathtracer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gkjohnson/three-gpu-pathtracer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/gkjohnson/three-gpu-pathtracer",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "gkjohnson2021gkjohnson"
  },
  {
   "role": "implementation",
   "key": "gh:mmp/pbrt-v4",
   "type": "code",
   "title": "mmp/pbrt-v4",
   "description": "Source code to pbrt, the ray tracer described in the forthcoming 4th edition of the \"Physically Based Rendering: From Theory to Implementation\" book.",
   "authors": [
    "mmp"
   ],
   "year": 2017,
   "venue": "GitHub",
   "url": "https://github.com/mmp/pbrt-v4",
   "ids": {
    "repo": "mmp/pbrt-v4"
   },
   "license": "Apache-2.0",
   "extra": {
    "stars": 3761,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-15T22:47:49Z",
    "language": "C++",
    "homepage": "https://pbrt.org",
    "license_name": "Apache License 2.0"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mmp/pbrt-v4",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mmp/pbrt-v4",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mmp/pbrt-v4",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mmp/pbrt-v4",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mmp/pbrt-v4",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mmp/pbrt-v4",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "mmp2017pbrt"
  },
  {
   "role": "implementation",
   "key": "gh:mitsuba-renderer/mitsuba3",
   "type": "code",
   "title": "mitsuba-renderer/mitsuba3",
   "description": "Mitsuba 3: A Retargetable Forward and Inverse Renderer",
   "authors": [
    "mitsuba-renderer"
   ],
   "year": 2021,
   "venue": "GitHub",
   "url": "https://github.com/mitsuba-renderer/mitsuba3",
   "ids": {
    "repo": "mitsuba-renderer/mitsuba3"
   },
   "license": "NOASSERTION",
   "extra": {
    "stars": 3003,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-28T12:37:12Z",
    "language": "C++",
    "homepage": "https://www.mitsuba-renderer.org/",
    "license_name": "Other"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mitsuba-renderer/mitsuba3",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mitsuba-renderer/mitsuba3",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mitsuba-renderer/mitsuba3",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mitsuba-renderer/mitsuba3",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mitsuba-renderer/mitsuba3",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mitsuba-renderer/mitsuba3",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "mitsubarenderer2021mitsuba"
  }
 ],
 "presets": [
  {
   "id": "path-tracing-tiny-scene",
   "title": "Tiny GLSL path tracer: spheres, floor, emissive lamp",
   "runtime": "glsl-fragment",
   "params": {
    "samples": 16,
    "bounces": 4
   },
   "code": "// GLSL ES 3.0, Shadertoy-style: diffuse path tracer with next-event-free emission gathering\nconst int SPP = 16;      // samples per pixel\nconst int BOUNCES = 4;   // path length\nuint seed;\nfloat rnd(){ seed = seed*747796405u + 2891336657u; uint w = ((seed>>((seed>>28u)+4u))^seed)*277803737u; return float((w>>22u)^w)/4294967295.0; }\nvec3 cosDir(vec3 n){\n  float u1 = rnd(), u2 = rnd(); float r = sqrt(u1), ph = 6.2831853*u2;\n  vec3 t = normalize(cross(n, abs(n.x) > 0.9 ? vec3(0,1,0) : vec3(1,0,0)));\n  vec3 b = cross(n, t);\n  return normalize(t*r*cos(ph) + b*r*sin(ph) + n*sqrt(1.0-u1));\n}\nvoid scene(vec3 ro, vec3 rd, out float tmin, out vec3 nor, out vec3 alb, out vec3 em){\n  tmin = 1e9; nor = vec3(0,1,0); alb = vec3(0.0); em = vec3(0.0);\n  if (rd.y < -1e-4) {\n    float t = (-1.0-ro.y)/rd.y;\n    vec3 p = ro+rd*t; float c = mod(floor(p.x)+floor(p.z), 2.0);\n    tmin = t; alb = mix(vec3(0.8,0.78,0.7), vec3(0.15,0.2,0.3), c);\n  }\n  vec4 S[4]; vec3 A[4]; vec3 E[4];\n  S[0] = vec4(-1.3,-0.2,-0.5,0.8); A[0] = vec3(0.8,0.2,0.15); E[0] = vec3(0.0);\n  S[1] = vec4( 0.9,-0.5,0.2,0.5);  A[1] = vec3(0.2,0.6,0.8);  E[1] = vec3(0.0);\n  S[2] = vec4( 0.2,-0.75,1.4,0.25);A[2] = vec3(0.9);          E[2] = vec3(0.0);\n  S[3] = vec4(sin(iTime)*1.5, 2.2, -0.5, 0.5); A[3] = vec3(0.0); E[3] = vec3(14.0,12.0,9.0);\n  for (int i = 0; i < 4; i++) {\n    vec3 oc = ro - S[i].xyz; float b = dot(oc, rd); float c = dot(oc,oc) - S[i].w*S[i].w;\n    float h = b*b - c; if (h < 0.0) continue;\n    float t = -b - sqrt(h);\n    if (t > 1e-3 && t < tmin) { tmin = t; nor = normalize(ro + rd*t - S[i].xyz); alb = A[i]; em = E[i]; }\n  }\n}\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord){\n  seed = uint(fragCoord.x) * 1973u + uint(fragCoord.y) * 9277u + 26699u;\n  vec3 col = vec3(0.0);\n  for (int s = 0; s < SPP; s++) {\n    vec2 uv = (fragCoord + vec2(rnd(), rnd()) - 0.5*iResolution.xy) / iResolution.y;\n    vec3 ro = vec3(0.0, 0.6, 5.0), rd = normalize(vec3(uv, -1.6));\n    vec3 thr = vec3(1.0), rad = vec3(0.0);\n    for (int k = 0; k < BOUNCES; k++) {\n      float t; vec3 n, alb, em; scene(ro, rd, t, n, alb, em);\n      if (t > 1e8) { rad += thr * mix(vec3(0.05,0.07,0.1), vec3(0.25,0.35,0.5), 0.5+0.5*rd.y); break; }\n      rad += thr * em;\n      if (dot(n, rd) > 0.0) n = -n;\n      ro = ro + rd*t + n*1e-3; rd = cosDir(n); thr *= alb;\n    }\n    col += rad;\n  }\n  col /= float(SPP);\n  fragColor = vec4(pow(1.0 - exp(-col), vec3(1.0/2.2)), 1.0);\n}",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "path-tracing",
     "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.4386,
      "std": 0.1476,
      "unique_colors": 283
     },
     "image": "/specimens/path-tracing-tiny-scene.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "multiple-importance-sampling",
  "bidirectional-path-tracing",
  "metropolis-light-transport",
  "photon-mapping",
  "path-guiding",
  "restir-di"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "multiple-importance-sampling",
   "why": "MIS weights merge light sampling and BSDF sampling at each vertex, removing the worst variance spikes."
  },
  {
   "id": "neural-radiance-caching",
   "why": "A learned cache terminates paths after a few bounces and supplies the remaining indirect radiance."
  },
  {
   "id": "restir-gi",
   "why": "Resampling reuses the one-sample indirect paths this integrator produces across pixels and frames."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/gi/path-tracing.json"
 },
 "solves": [
  "need physically accurate lighting with global illumination",
  "reference quality renders for comparison",
  "caustics, reflections and bounce light all in one method",
  "simple unbiased renderer handling any material"
 ],
 "authority": "Kajiya, 1986",
 "url": "https://texelatlas.vercel.app/t/path-tracing/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 92.97,
  "tier": "extreme",
  "p50_ms": 3.0588,
  "p95_ms": 3.1542,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "path-tracing-tiny-scene",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 79.57,
   "tier": "extreme",
   "p50_ms": 1.2652,
   "p95_ms": 1.2908,
   "speedup_x": 2.42,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 57.14,
   "tier": "heavy",
   "p50_ms": 1.6456,
   "p95_ms": 1.6527,
   "speedup_x": 1.86,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}