Making Ray Tracing from Scratch

Problem

This project builds a baseline renderer for ray tracing in C++17. The program generates a synthetic 3D scene (many spheres with different materials), traces rays from a virtual camera, and outputs a rendered image as a PPM file.

Why this problem is interesting:

The baseline is intentionally serial and simple so it can be parallelized later in the course.

How the algorithm/baseline code works

raytrace.cpp implements a small serial path tracer:

  1. Scene generation
  2. Camera and rays
  3. Ray-object intersection
  4. Material scattering (path tracing loop)
  5. Accumulation and output

Example compile and run:

clang++ -O3 -Wall -std=c++17 raytrace.cpp -o raytrace
./raytrace --width 960 --height 540 --spp 64 --max-depth 12 --small-spheres 120 --seed 12345 --output raytrace.ppm

Where is parallelism

This application has ample parallelism.

Expected multicore/GPU approach (later assignments):

Possible speedup limits: