Monte Carlo Sampling

By: Steven Udall


This is an implementation of Monte Carlo Sampling into a ray tracer. Sampling ray directions were chosen based on cosine weighted hemisphere Lambertian BRDF for diffuse emission and Phong BRDF for specular reflection. Rays are weighted based on importance to the total pixel color and terminated when their weight is below a certain percentage threshold using Russian Roulette or when they have exceeded the maximum bounce depth. Direct lighting was also added to help the scene converge faster. For lighting, a spherical area light source was used. Below is a 10 sample image of a scene followed by a 2500 sample image of the same scene. Of course, as more samples are taken, the pixel color converges toward the expected color; therefore, there are still some pixels not colored correctly even 2500 samples and 29 hours later.


Lambertian Lighting BRDF

Phong BRDF

Implementing MC into a raytracer and easy to understand explaination of how Monte Carlo sampling works

Monte Carlo details

Rotating a vector about an axis using quaternions

Monte Carlo and importance sampling