All projects

Personal project · 2026

Path Tracer, CPU & Vulkan

A physically based Monte Carlo path tracer in C++ that expands on the Ray Tracing in One Weekend series, plus a headless Vulkan compute port of the renderer.

  • C++
  • Path tracing
  • Vulkan
  • GLSL
  • BVH
  • Multithreading
The final scene of Ray Tracing in One Weekend: a glass, a brown diffuse and a metal sphere surrounded by hundreds of small colored spheres, with a shallow depth of field.
Static frame Path traced · 4096 spp
The final scene of Ray Tracing in One Weekend, path traced on your GPU by a WebGPU port of my Vulkan renderer. It only starts on devices that can run it smoothly, pauses when off screen, and lets the GPU rest once the image has converged.

A path tracer written from scratch in C++. It started as a walk through Peter Shirley’s Ray Tracing in One Weekend series, all three books, and grew into a renderer that loads textured glTF and OBJ models, renders with every core of the machine, and has a second backend running on the GPU through Vulkan.

The viewport at the top of this page is a third version: the Vulkan compute shader ported to WebGPU, rendering the first book’s final scene live in your browser. Drag to orbit and click to focus; it only starts on GPUs that can run it smoothly, and stops working once the image has converged.

CPU renderer

  • Materials: Lambertian, metal with roughness, dielectrics with Schlick’s Fresnel approximation, emissive lights and isotropic participating media.
  • Geometry: spheres (including moving spheres for motion blur), quads, triangles, disks, ellipses, annuli, planes, boxes, cylinders and cones, plus instancing transforms.
  • Meshes: OBJ and glTF 2.0 import through tinyobjloader and cgltf, with a per-mesh BVH and automatic camera framing.
  • Textures: image textures, checkers, Perlin noise with turbulence and marble patterns, UV scaling, and an image-based sky dome.
  • Acceleration: bounding volume hierarchy over the whole scene.
  • Sampling: stratified pixel samples, cosine-weighted hemisphere sampling, explicit light sampling and mixture PDFs to cut variance, as covered in The Rest of Your Life.
  • Performance: multithreaded rendering that hands out image rows through an atomic counter. The final scene of The Next Week went from about 24 hours to about 1 hour.
  • CLI: scenes are registered by name, and any .obj, .gltf or .glb file can be rendered directly.

Vulkan GPU renderer

A headless Vulkan port that runs the path tracer as a GLSL compute shader, with no window or swapchain. Sphere and camera data live in storage buffers, the shader is compiled to SPIR-V at build time, and the image is accumulated over several dispatches, both to keep each one under the GPU watchdog timeout and so that every batch draws fresh random numbers. The result is written to a PPM file.

Variance reduction

Stratification spreads each pixel’s samples over a grid of sub-cells instead of leaving them to chance, which removes clumps and gaps in the sampling pattern. Combined with sampling the light directly and mixing that with the material’s own distribution, the same number of samples gives a visibly cleaner image.