Real time path tracer in DirectX 12 with SHARC radiance caching, path guiding, optimized ReSTIR spatial reuse, a four lobe layered BXDF, light tree importance sampling with learned light cuts, and NVIDIA DLSS for upscaling and denoising.
The path tracer uses the DXR HitObject API with Shader Execution Reordering (SER). The regular pipeline consists of three main stages:
- SHARC: Sparse update paths, radiance cache resolve, and path guiding updates.
- Path tracing: Multi-bounce tracing with light tree NEE, learned light cuts, guided BSDF sampling, and SHARC queries.
- ReSTIR spatial reuse: Texture-based partner selection, reconnection and visibility evaluation, followed by pairwise MIS merging.
SHARC training and rendering share the light sampler and material model. Training also updates the directional guide. Spatial reuse operates on the resulting render samples within the current frame.
A light tree over the scene's emissive triangles provides importance sampling for scenes with many lights. The tree uses a TLAS/BLAS hierarchy with geometric importance weights based on emitted power, distance, and orientation.
Learned light cuts adapt emitter selection using visibility-weighted contribution feedback. Spatial cells store cuts of up to 32 clusters, with online splitting and merging. Cells are separated by surface orientation and retain history during camera movement. The learned sampler is used in both path tracing and SHARC training.
SHARC example: interior illumination.
Spatially Hashed Radiance Caching with a sparse world-space hash grid, distance-adaptive cell spacing, and temporal accumulation. A rotating subset of pixels supplies cache updates. Entries store material-demodulated radiance and statistical confidence.
Cache queries replace eligible diffuse and rough reflection contributions at secondary surfaces. Surface identity, normal and plane compatibility, confidence, and path footprint control acceptance. Direct lighting at primary surfaces remains traced, and rejected queries continue normally. Cache termination introduces spatial and temporal approximation error.
| Path guiding off | Path guiding on |
|---|---|
Path guiding uses up to eight directional lobes per spatial cell, fitted from SHARC training paths. Lobes store direction, angular extent, weight, and a distance estimate for parallax correction. Stale lobes decay, with fallback to coarser cells when local support is unavailable.
Guided directions are mixed with diffuse and rough reflection BSDF sampling. The matching mixture PDF is used for path weighting and MIS.
ReSTIR spatial resampling for diffuse and rough reflection contributions using 32-byte reservoirs. Three precomputed, self-inverting reuse textures provide reciprocal pixel partners, following ReSTIR PT Enhanced.
Separate shift and merge passes cache reconnected contributions and visibility for pairwise MIS. Reciprocal pairing makes both pixels' evaluations available to the merge. Repeated samples reuse visibility results, and full neighbor payloads are loaded only on reservoir selection. Material and geometric checks reject incompatible pairs. The regular pipeline uses spatial reuse only.
The ReSTIR PT hybrid shift mode is deprecated.
Cumulative comparison: base path tracing, learned light cuts, SHARC, then path guiding and ReSTIR spatial reuse.
| 1 · Base path tracing | 2 · + Learned light cuts |
|---|---|
| 3 · + SHARC | 4 · + Path guiding and ReSTIR |
| Transmission | Sheen | Metal | Clearcoat | SSS |
Material examples, including subsurface scattering (SSS).
A four lobe BXDF with layered evaluation:
- Sheen: Charlie NDF for fabric-like surfaces.
- Clearcoat: Dielectric GGX with independent roughness and Fresnel.
- GGX Specular/Transmission: Anisotropic microfacet model with VNDF importance sampling. Nested dielectrics use per-bounce IOR stack tracking.
- Lambertian Diffuse: Cosine-weighted base layer.
Subsurface scattering uses volumetric random walks. Emission is evaluated separately from the scattering lobes.
Supports OBJ and glTF/GLB via tinyobjloader and tinygltf. Textures use stb_image with DDS decompression through DirectXTex. Models, materials, and per-instance transforms share a unified scene representation.
Alpha-tested geometry uses Opacity Micromaps, built with the NVIDIA OMM SDK. Opacity is encoded per microtriangle in the BVH, allowing hardware traversal to skip transparent regions without any-hit shader invocations.
NVIDIA DLSS Ray Reconstruction provides denoising and upscaling through Streamline.
Minecraft worlds are supported with chunk streaming, adaptive LOD, and asynchronous geometry builds. Emissive block geometry is sampled through the light tree.
Example statistics from a recorded Greenfield v0.5.4 run:
| Metric | Count |
|---|---|
| Rendered triangles | 86.13 million |
| Emissive triangles in the active light tree | 1.29 million |
| World chunks | 295,936 across 356 regions |
| Materials | 10,451 |
| Textures | 5,253 |
Geometry and light counts vary with camera position and LOD.
What started as a port of the RoyalTracer university project to DirectX became a standalone rendering engine. In my Bachelor's Thesis, I implemented and optimized ReSTIR to improve real time rendering. Current work focuses on learned sampling, radiance caching, and spatial reuse.
Requires Windows 11, an NVIDIA RTX 40 series GPU or newer, Visual Studio 2022 with C++ build tools and Windows SDK 10.0.22621.0, and CMake 3.25.2 or newer.
Run from the repository root:
cmake -S Pathtracer -B Pathtracer/build -G "Visual Studio 17 2022" -A x64
cmake --build Pathtracer/build --config Release| Input | Action |
|---|---|
| W / A / S / D | Move |
| Space / Left Ctrl | Ascend / descend |
| Left mouse drag | Look around |
- Scenes: Amazon Lumberyard Bistro (NVIDIA ORCA), Crytek Sponza, Minecraft Greenfield.
- NVIDIA libraries: Streamline, OMM SDK.
- Asset loaders and texturing: tinyobjloader, tinygltf, stb_image, DirectXTex.
- UI: Dear ImGui.
Bistro.
Sponza.
| Harbor | Harbor at night |
| Ship | Skyline |
Island.