Project 3: Distribution Ray Tracing
Due Mar 6 by 11:59pm Points 100 Submitting a file upload
Available Feb 18 at 9pm - Mar 9 at 11:59pm
Start Assignment
Objective
For this project, you will add distribution ray tracing functionality to your ray tracer. First, you will add
spheres as a new kinds of primitive. You will also create shading effects for shiny surfaces (highlights
and reflection). Then you will begin to cast more than one ray per pixel, at first just for anti-aliasing.
Finally, you will build on this to achieve several distribution ray tracing effects: soft shadows, motion blur,
depth-of-field, and glossy reflection.
Project Description
This project will require you to implement a number of new effects:
1. Add spheres as new geometric primitives
2. Add specular terms to the surface material properties
3. Perform recursive ray tracing for reflective surfaces
4. Add anti-aliasing and soft shadows (using disk lights)
5. Implement more soft effects: motion blur, glossy reflection, and depth of field
After you implement these new capabilities, your results should appear almost exactly like the examples
shown below in Results.
Begin with Your Project 2 Code
There is no provided code for this project. Since this project builds on top of Project 1 and 2, you should
start with your project 2 code and add the new capabilities to it.
Provided Scene Files
There are several SCENE FILES (https://gatech.instructure.com/courses/295972/files/39583451?wrap=1)
(https://gatech.instructure.com/courses/295972/files/39583451/download?download_frd=1) that are
provided for this project. Scene files are provided in pairs, with "a" and "b" versions. You should modify
your code so that pressing one of the keys 1-9 will load in the appropriate "a" scene file. When you
press SHIFT and the digit 1-9, your code should read in the "b" version of the scene.
Scene Description Language
As in Projects 1 and 2, each scene is described by a text file with suffix ".cli". Each of these .cli files are
just plain text files, and you are encouraged to look at them. Sometimes you may find it useful to modify
a copy of these files to make debugging easier.
Below are the new commands that you will implement. Your ray tracer should also keep the functionality
of all of the commands from Projects 1 and 2.
sphere radius x y z
Create a sphere with a given radius and center location.
rays_per_pixel num
Specify how many rays per pixel to shoot. By default, this value should be set to one. When the number
of rays is larger than one, sub-pixel rays should be created in random positions within each pixel. The
colors of these rays should be averaged together to give the final color of the pixel.
moving_object dx dy dz
Change the last object that was defined into a moving object. The values (dx, dy, dz) specify the
amount of translation this object undergoes during one frame. Rays shot at such an object should
assigned a random time in the range of 0 to 1. The moving object should be translated by this random
time amount times the displacement (dx, dy, dz). When many rays per pixel are used, this should give
the appearance of motion blur. You can implement this in a manner similar to an instanced object, by
translating the incoming ray's origin. Remember that any shadow rays shot from this object should use
the same random time!
disk_light x y z radius dx dy dz r g b
Create a disk light source, with center (x, y, z), a given radius, the direction that the light is facing (dx,
dy, dz), and the light color (r, g, b). Shadow rays should be shot to random locations on this disk. When
many rays per pixel are used, this should create soft shadows.
lens radius dist
When radius is non-zero, this command will create depth of field effects by shooting rays from a lens.
The origin of the eye rays should not be exactly at (0, 0, 0), but from a random point on the lens. The
lens is a disk that is centered at the origin of the given radius, and that is perpendicular to the z-axis.
The value dist gives the distance to the focal plane that is perpendicular to the z-axis. All rays for a
given pixel, no matter where they originate on the lens, should pass through the same point P on the
focal plane.
glossy dr dg db sr sg sb spec_pow k_refl gloss_radius
Create a shiny surface material. The first three values (dr dg db) are the diffuse color coefficients, just
as in the "surface" command. The next three coefficients (sr sg sb) are the specular color coefficients,
and should only affect the colors of the specular highlights. The spec_pow value should affect the
apparent roughness of the surface, with higher values giving tighter highlights. (See section 10.2 of
Fundamentals, equation 10.7). A non-zero value for k_refl indicates the surface is shiny enough to
shoot reflected rays and indicates how much they contribute to the surface color. When gloss_radius is
zero, the direction of the reflected rays should travel in the perfect mirror direction. When gloss_radius
is greater than zero, modify the perfect mirror direction by adding a "fuzz factor" taken from a random
vector inside a sphere of the given radius. When multiple rays per pixel are used, this will give the
impression of glossy reflection.
Random Sampling and Filtering
Although jittered sampling is a very good way to create samples for pixel anti-aliasing, we will not be
requiring the use of jittered sampling. There are several reasons for this: 1) it is awkward to do jittered
sampling for non powers of two (e.g. 50 samples), and 2) it is hard to do jittering correctly for multiple
soft effects at once (pixel anti-aliasing, soft shadows, depth of field, etc.). Instead of using jittered
sampling, we recommend that you use random samples in the given sampling region for each soft
effect. For pixel anti-aliasing, pick a random fractional location for every eye ray within each square
pixel. For each shadow ray, pick a random location on the disk-shaped point light source (using rejection
sampling). For each motion blurred object, pick a random time in the range of zero to one. For each
lens sample for depth-of-field, pick a random point on the disk of the lens (again with rejection
sampling). For each glossy reflection, choose a random point in the "fuzzy" sphere (rejection sampling!)
to make your reflections different than the ideal reflected direction.
During the lecture on anti-aliasing, we saw that a box filter is actually not the best filter for anti-aliasing.
However, we want you to use a box filter for this project for pixel anti-aliasing. Using a better filter, such
as a triangle or Gaussian filter would be better, but would make the project overly complicated. Please
stick with box filter, that is, just average all of the pixel rays together without giving them different
weights.
Results
The scenes for this project are given in pairs, and each filename contains either the letter a or b. When
you press any of the digits 1 to 9, this should cause the "a" version of the scene to be rendered. When
you press the SHIFT key and a digit 1 to 9 (characters !@#$%^&*( ), this should cause the "b" scene to
be rendered. Many (but not all) of the "b" scenes shoot more than one ray per pixel. Below are the
images that your program should generate for a given scene, and the "a" and "b" scene images are
shown on the same row.
Authorship Rules
The code that you turn in entirely your own. You are allowed to talk to other members of the class and to
the instructor and the TA’s about general implementation of the assignment. It is also fine to seek the
help of others for general Processing/Java programming questions. You may not, however, use code that
anyone other than yourself has written. The only exception is that you should build on the code that you
wrote for Project 1 and 2. Code that is explicitly not allowed includes code taken from the Web, github,
from books, from the processing.org web site, from other students or from any source other than
yourself. You should not show your code to other students. Feel free to seek the help of the instructor
and the TA's for suggestions about organizing and debugging your code.
Submission
You will turn in your code via Canvas. In order to run Processing source code, it must be in a folder
named after the main pde file. For this reason, when submitting your project, you should keep your code
in this folder, zip up this folder, and submit this single zip file via Canvas. Make sure that your project
folder contains the "data" sub-folder and the .cli files it contains. Please do not use tar or rar to turn in
your files.