Making a Pure Path Tracer from Scratch

Problem

In this assignment, I implement path tracing, a core algorithm in computer graphics, from scratch in C++ without external libraries. The target scene is a Cornell box (a box-shaped interior) with:

The renderer outputs a PPM image, and image noise decreases as the number of samples per pixel (spp) increases.

This is a realistic application and is a good baseline for later parallelization (multicore CPU and GPU), where performance improvements can be measured clearly.

How the algorithm/baseline code works

The implementation is in code/pathtracer.cc. The main steps are:

  1. Scene construction
  2. Intersection tests
  3. Path tracing (pure path tracing)
  4. Output and verification metrics

Execution parameters are configurable from the command line:

By changing these parameters, runtime can be scaled from seconds to a few minutes.

Where is parallelism

This baseline has abundant data parallelism: