View on GitHub

Cardinal3D

Stanford CS248A (Assignments 2 and 3)

(Task 5) Path Tracing (EXTRA CREDIT)

Up to this point, your renderer simulates light which begins at a source, bounces off a surface, and hits a camera. However in the real world, light can take much more complicated paths, bouncing of many surfaces before eventually reaching the camera. Simulating this multi-bounce light is referred to as indirect illumination, and it is critical to producing realistic images, especially when specular surfaces are present. In this task you will modify your ray tracer to simulate multi-bounce light, adding support for indirect illumination.

You must modify Pathtracer::trace_ray to simulate multiple bounces. We recommend using the Russian Roulette algorithm discussed in class.

The basic structure will be as follows:

Step 2

Now, Implement BSDF_Lambertian::sample for diffusely reflecting, which randomly samples from the distribution and returns a BSDF_Sample. Note that the interface is in rays/bsdf.h. Task 6 contains further discussion of sampling BSDFs, reading ahead may help your understanding. The implementation of BSDF_Lambertian::evaluate is already provided to you.

Note:


After correctly implementing path tracing, your renderer should be able to make a beautifully lit picture of the Cornell Box. Below is the rendering result of 1024 sample per pixel.

cornell_lambertian

Note the time-quality tradeoff here. With these commandline arguments, your path tracer will be running with 8 worker threads at a sample rate of 1024 camera rays per pixel, with a max ray depth of 4. This will produce an image with relatively high quality but will take quite some time to render. Rendering a high quality image will take a very long time as indicated by the image sequence below, so start testing your path tracer early! Below are the result and runtime of rendering cornell box with different sample per pixel at 640 by 430 on Macbook Pro(3.1 GHz Dual-Core Intel Core i5).

spheres

Also note that if you have enabled Russian Roulette, your result may seem noisier.

Here are a few tips:

Extra Credit Ideas