Monte Carlo Path Tracer
March 13, 2024

A path tracer written in C++ using OpenGL and GLSL.



The path tracer shoots rays from the camera into the scene, bouncing off surfaces and sampling light sources to calculate the color of each pixel.

The path tracer uses Monte Carlo integration to estimate the color of each pixel by sampling multiple rays and averaging their contributions.

It supports two sampling strategies: sampling the light source and sampling the surface.

Its light sampling strategy accounts for point, spot, and area lights. Area and spot lights scene below.


Its material system supports diffuse, specular, transmissive, metallic, and microfacet materials with adjustable roughness.

The following scenes shows spheres with smooth glass, rough glass, rough microfacet, diffuse, and metallic materials.


Its glass shader also supports chromatic dispersion by handling the rgb channels separately on reflection, which causes the glass to split light into its component colors.


The path tracer supports both sphere and triangle meshes.

Here is a scene based portions of a imported character model. It shows the metallic material and its abiltiy to sample textures.


The path tracer also supports depth of field using the thin lens model.


This project was a great learning experience in computer graphics and ray tracing. I learned about the math behind ray tracing, how to implement a path tracer, and how to optimize it for performance.