Final Project
Raytracer with Depth of Field, Subpixel Jittering, and Soft Shadows extensions


Siqi Chen



For my final project, I have extended the high level raytracer code to support depth of field, subpixel jittering, and soft shadows. All of these can be toggled on and off at run time. The parameters for each are configurable at compile time. I have also created scenes which demonstrates some of these effects.


Subpixel Jittering ('a' to turn off, 'A' to turn on)

The basic subpixel jittering algorithm is implemented as described in the textbook, with each subpixel being sampled randomly after subdivision. The number of subpixels per pixel (as well as the radius at which a pixel is considered) is configurable at compile time. Most images were rendered at 4x4 = 16 subpixels, with a pixel radius of 1.0 units.

This was a relatively straight forward extension to implement. One of the problems I encountered was that my images were very overbright initially. It took almost an hour to figure out why: it turns out I forgot to zero the accumulator pixel after rendering a new pixel.

Subpixel OnWith Subpixel Jittering
Subpixel OffWithout Subpixel Jittering




Depth of Field
('d' to turn off, 'D' to turn on)


The basic depth of field algorithm was not difficult to implement. For convenience, the number of jittered rays is equal to the number as used for subpixel jittering. The amount of jittering is configurable at compile time. It is set at 0.25 - 0.50 unit radius for the images rendered here. I have also implemented a seperate algorithm in order to use depth of field and subpixel jittering at once without the performance decrease as described in the textbook. The below image is focused on the third sphere from the left.

DOF ONWith Depth of Field
DOF OFFWithout Depth of Field




Soft Shadows
('s' to turn off, 'S' to turn on)


I have implemented a basic form of soft shadowing with extended lights. By turning on the soft shadows option, the raytracer will consider all light sources to be an extended square light parallel to the ground plane. The SoftShadowFeeler subroutine will then run the jittering algorithm on the light sources (using n^2 rays) to see how much of the light is occluded. Then the illumination at that point is set accordingly. The below pictures have two lights directly overhead.

Soft OnWith Soft Shadows
Soft OffWithout Soft Shadows











And finally,

A Digusting Piece of Abstract Art Which I Call
"The Toiletry of Sophistry, Alone"

high quality rendering
Really expensive rendering with a lot of rays and everything turned on. (6 hours on a 3ghz P4)