Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

readme.md

pathTracing

A progressive path-traced view of the scene through the active camera — the converged image the real-time renderer is trying to approximate, on screen next to it.

The engine's existing path tracers answer "what light arrives at this surface" and write the answer into a lightmap or a probe field. This points the same transport at the camera: every pixel is a path, and what comes back is a reference image. Held still, it converges over seconds; move the camera and it starts again.

Using it

local referenceView = require("@builtin::systems.pathTracing.referenceView")

referenceView.enable({ samplesPerFrame = 4, bounces = 5 })
-- ... let it converge ...
print(referenceView.settings().samples)   -- how far along it is
referenceView.disable()

enable snapshots the scene's geometry and lights into GPU buffers and starts tracing. refresh() retakes that snapshot after the scene changes; reset() restarts the accumulation without re-snapshotting, for a change the view cannot see by itself (a light retuned in place). The camera is watched automatically — any movement restarts it.

settings() reports samples (how many are in the displayed image), converged (whether it has reached maxSamples), and the size of the scene snapshot in triangles, nodes and lights.

What it traces

  • Geometry — every visible mesh-bearing world entity, movable ones included, as a BVH built by compute.buildBvh. Alpha-cutout surfaces are traced through their coverage masks, so foliage reads as foliage.
  • Materials — the albedo, emissive, roughness and metallic the raster path shades with, through a GGX-over-Lambert microfacet BSDF split by metalness. Both lobes are importance-sampled, and paths terminate by Russian roulette rather than at a fixed depth.
  • Lights — every light the bake gathers: directional, point, spot, ambient and area. Area lights are sampled per path, so their penumbrae emerge from the accumulation rather than being approximated.

Shape

PieceRole
referenceView.moduleThe public surface. Owns the scene snapshot, the accumulation state, and the camera watch.
pathTrace.renderFeatureThe GPU passes: trace-and-accumulate, resolve, blit. Enqueues nothing while the view is disabled.

The tracer renders the camera the view was enabled for, from parameters the module packs, rather than the camera of whichever render target a pass runs in. One accumulation belongs to one camera, so an offscreen capture drawn in the same frame shows the same converged image instead of resetting it.

Everything is buffer-bound: no hardware ray tracing, no deferred G-buffer, and so the same code on either backend and either platform.