A simple path tracer written in C++ as an assignment for a Predictive Image Synthesis Technologies - NPGR026. The program contains a single hardcoded scene and thus can serve only as a studying material on the internals of the pathtracing algorithm.

The assignment was to write a simple path tracer that would produce a scene where two unit spheres are sitting on each other (touch only at one point). Plus the base plane on which the lower sphere rests (again only one touching point).

The top sphere was to be a perfectly diffuse emmiter with radiance defined as RGB(1,1,1). All other surfaces were to be perfectly diffuse surfaces with RGB(1,1,1).

A special feature of the scene is that radiance reflected on the surface of the lower sphere in the touching point is exactly 1. In the stage two of the assignment we were to add a lightsource sampling the code.

Parts of the code inspired by smallpt program written by Kevin Beason which is a condensed path tracer written on 99 lines of C++ code. Though, a bit harder to read.

The code is tied to *NIX platforms due to the use of erand48 function. Though it shouldn't be particularly hard to change all erand48 calls for a normal rand calls. A care must be taken to decorrelate random numbers for each pixel and proper thread safety if one would want to use parallelisation.

Features

  • Hardcoded scene described above
  • Lambertian surface BRDF sampling
  • Lightsource sampling
  • OpenMP parallelisation support (switchable via LDFLAGS variable inside the makefile)

Resources

Screenshots