Unidirectional Path Tracing
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.
Also known as PT, Monte Carlo path tracing, Kajiya path tracing
In the family Light transport & global illumination, Monte Carlo light transport
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Plugin | npm i three-gpu-pathtracer docs |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | |
| Unity | Built in | Volume > Add Override > Ray Tracing > Path Tracing docs HDRP only, requires DXR/Vulkan ray tracing hardware. |
| Unreal 5.7 | Built in | Project Settings > Rendering > Hardware Ray Tracing > Support Hardware Ray Tracing, then Viewport > Lit > Path Tracing docs |
| Blender 5.2 | Built in | Properties > Render > Render Engine = Cycles docs Cycles is a unidirectional path tracer. |
| WebGPU W3C | None found | |
| Metal | None found | Hardware ray intersection is built in (MTLAccelerationStructure); the path-tracing integrator is yours to write. |
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.
Two 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.
Because 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 choose it
Reach for it when
- 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
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: Spatiotemporal Reservoir Resampling for Direct Lighting / ReSTIR GI: Path Resampling for Real-Time Path Tracing resampling and denoisers are built on.
Prefer Bidirectional Path Tracing or Vertex Connection and Merging when light mostly arrives through small openings or specular chains (caustics, lamps behind glass). Prefer Photon Mapping for caustics at low cost. Prefer Practical Path Guiding when plain sampling is too noisy on hard indirect paths. Prefer Dynamic Diffuse Global Illumination (DDGI) or SDF-Based Software Ray Tracing GI (Lumen-style) when you need a few milliseconds per frame rather than converged images.
Field marks
- 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
Presets
Tiny GLSL path tracer: spheres, floor, emissive lamp
{
"samples": 16,
"bounces": 4
}Show GLSL (49 lines)
// GLSL ES 3.0, Shadertoy-style: diffuse path tracer with next-event-free emission gathering
const int SPP = 16; // samples per pixel
const int BOUNCES = 4; // path length
uint seed;
float rnd(){ seed = seed*747796405u + 2891336657u; uint w = ((seed>>((seed>>28u)+4u))^seed)*277803737u; return float((w>>22u)^w)/4294967295.0; }
vec3 cosDir(vec3 n){
float u1 = rnd(), u2 = rnd(); float r = sqrt(u1), ph = 6.2831853*u2;
vec3 t = normalize(cross(n, abs(n.x) > 0.9 ? vec3(0,1,0) : vec3(1,0,0)));
vec3 b = cross(n, t);
return normalize(t*r*cos(ph) + b*r*sin(ph) + n*sqrt(1.0-u1));
}
void scene(vec3 ro, vec3 rd, out float tmin, out vec3 nor, out vec3 alb, out vec3 em){
tmin = 1e9; nor = vec3(0,1,0); alb = vec3(0.0); em = vec3(0.0);
if (rd.y < -1e-4) {
float t = (-1.0-ro.y)/rd.y;
vec3 p = ro+rd*t; float c = mod(floor(p.x)+floor(p.z), 2.0);
tmin = t; alb = mix(vec3(0.8,0.78,0.7), vec3(0.15,0.2,0.3), c);
}
vec4 S[4]; vec3 A[4]; vec3 E[4];
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);
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);
S[2] = vec4( 0.2,-0.75,1.4,0.25);A[2] = vec3(0.9); E[2] = vec3(0.0);
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);
for (int i = 0; i < 4; i++) {
vec3 oc = ro - S[i].xyz; float b = dot(oc, rd); float c = dot(oc,oc) - S[i].w*S[i].w;
float h = b*b - c; if (h < 0.0) continue;
float t = -b - sqrt(h);
if (t > 1e-3 && t < tmin) { tmin = t; nor = normalize(ro + rd*t - S[i].xyz); alb = A[i]; em = E[i]; }
}
}
void mainImage(out vec4 fragColor, in vec2 fragCoord){
seed = uint(fragCoord.x) * 1973u + uint(fragCoord.y) * 9277u + 26699u;
vec3 col = vec3(0.0);
for (int s = 0; s < SPP; s++) {
vec2 uv = (fragCoord + vec2(rnd(), rnd()) - 0.5*iResolution.xy) / iResolution.y;
vec3 ro = vec3(0.0, 0.6, 5.0), rd = normalize(vec3(uv, -1.6));
vec3 thr = vec3(1.0), rad = vec3(0.0);
for (int k = 0; k < BOUNCES; k++) {
float t; vec3 n, alb, em; scene(ro, rd, t, n, alb, em);
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; }
rad += thr * em;
if (dot(n, rd) > 0.0) n = -n;
ro = ro + rd*t + n*1e-3; rd = cosDir(n); thr *= alb;
}
col += rad;
}
col /= float(SPP);
fragColor = vec4(pow(1.0 - exp(-col), vec3(1.0/2.2)), 1.0);
}Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| path-tracing-tiny-scene | Tesla T4 1920x1080 | 93.0× baseline (extreme) · 3.06 ms / 3.15 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| path-tracing-tiny-scene | NVIDIA L4 1920x1080 | 79.6× baseline (extreme) · 1.27 ms / 1.29 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| path-tracing-tiny-scene | NVIDIA A100-SXM4-40GB 1920x1080 | 57.1× baseline (heavy) · 1.65 ms / 1.65 ms · 1.9× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Radiosity (Hemicube Form Factors); cited by Hashed alpha testing / alpha-to-coverage for foliage, Manifold Next-Event Estimation and Specular Manifold Sampling, Precomputed Radiance Transfer, Real-time glints (distributed binomial laws), Stylized nonlinear Monte Carlo rendering, Lightweight WGSL Temporal-Spatial Neural Denoiser for Stochastic Splatting, Thin-film iridescence, Vertex Connection and Merging, Weathering simulation (weathered stone).
Crosses
- Multiple Importance Sampling: MIS weights merge light sampling and BSDF sampling at each vertex, removing the worst variance spikes.
- Neural Radiance Caching: A learned cache terminates paths after a few bounces and supplies the remaining indirect radiance.
- ReSTIR GI: Path Resampling for Real-Time Path Tracing: Resampling reuses the one-sample indirect paths this integrator produces across pixels and frames.
Sources
- primaryJames T. Kajiya (1986). The rendering equation. Proceedings of the 13th annual conference on Computer graphics and interactive techniques.Verified via crossref · 2026-11-29doi:10.1145/15922.15902
- tutorialMatt Pharr, Wenzel Jakob, Greg Humphreys. Path Tracing (Physically Based Rendering, 3rd edition). pbr-book.org.Verified via live page · 2026-11-29
- implementationgkjohnson (2021). gkjohnson/three-gpu-pathtracer. Path tracing renderer and utilities for three.js built on top of three-mesh-bvh.GitHub API · license MIT · 2026-11-29
- implementationmmp (2017). mmp/pbrt-v4. Source code to pbrt, the ray tracer described in the forthcoming 4th edition of the "Physically Based Rendering: From Theory to Implementation" book.GitHub API · license Apache-2.0 · 2026-11-29
- implementationmitsuba-renderer (2021). mitsuba-renderer/mitsuba3. Mitsuba 3: A Retargetable Forward and Inverse RendererGitHub API · license NOASSERTION · 2026-11-29