|
15-462 Programming Assignment 3: Ray Tracing Due Tuesday November 18, 11:59pm |
Overview
In this assignment, you
will be building a ray tracer. As already discussed in lecture, ray tracing is
a powerful method for performing global illumination. Ray tracers are widely
used to render photorealistic images and animations. You can try the
interactive ray tracer [8] to see
how the ray tracer works step by step. Examples of globally illuminated renders
of a Cornell Box (some ray traced) can be found at Henrik
Wann Jensen's page at [6]. Also, you
might want to take a look at the Internet Ray Tracing Competition for
inspiration [7]. Other useful materials
on ray tracing are in the links section at the end of this handout.
At the end of this
assignment, your ray tracer should be able to minimally handle opaque surfaces
with lighting, shadows, reflections and texture mapping. Provided for you will
be some starter code that performs some elementary parsing functions.
Sending out rays
The first step is to
uniformly send out rays from the camera location. You will need to use
backwards ray tracing where rays are sent from the camera, one ray per pixel.
For your project submission, the image size must be 640x480.
In the starter code, the width and the height have been reduced to help you
debug more quickly. Your code should work on any dimension.
When generating your
scene, use a perspective projection "camera" with the camera
properties specified by the input scene file. This will allow you to
standardize images for testing.
Intersection Testing
The next step would be
to write code for intersections and texture mapping. The mathematical solutions
for the intersection and texture mapping code are provided in the lecture notes
and handouts.
In order to perform Phong shading, normals are
required. For triangles, you can interpolate the x, y, and z
coordinates of the normals at each vertex, and then
normalize their length. We recommend using barycentric
coordinates for interpolation of triangles. For spheres, the normal is simple
to calculate from the center of the sphere.
You are also required to
implement texture mapping for triangles and spheres. For triangles, interpolate
the texture coordinate using barycentric coordinates.
For spheres, we recommend using spherical coordinates for texture mapping.
Illumination
The third step in the
process would be to implement the illumination equations. The illumination
equation for a surface point is given by:
I = (ka *
Ia) + Ii * (kd * (L . N) + ks * (R . V)n)
Note that in the ideal
ray tracer, there should be no ambient effect. That would make the area the
light cannot reach completely dark.
For materials with a
non-zero specular component, you need to recurse (upto a maximum depth of
at least 3). To add in the value of this recursive ray, use the following
formula:
Ifinal = I + ks * Ir
Implementation
Starter Code
Starter code in C/C++, a
Makefile, and some useful libraries can be accessed
at http://www.cs.cmu.edu/~462/projects/assn3/assn3-starter.tar.gz [1].
The starter code is
intended to provide you sample utility functions and the xml parser code. You
may find some parts of the program to be unnecessary or inefficient to your
program. In that case, please feel free to change or remove them.
You will only need to
implement trace_pixel(Scene* scene, int x, int y) in raytrace_RT.cpp to return the correct
color to be displayed at the screen coordinate (x,y)
given the scene. The screen-coordinates start with (0, 0) at the bottom-left
corner up to (WINDOW_WIDTH-1, WINDOW_HEIGHT-1) at the top-right.
The starter-code also
allows you to dynamically change your position in 3D Space using the mouse and
the ctrl-key and preview how openGL, not your ray
tracer, would render the scene. The should allow you
to check your camera and perspective calculations against your ray tracer.
Other important files
are:
Object Types
There are 3 pre-defined
object types in the starter code. Your program must support ray tracing for
each of these object types.
For each object type, Scene.h also defines the rigid body transformation
parameters including rotation angles, scales, and translation units. These transformation allow you to create an ellipsoid, to rotate,
and to move model objects. For the requirement submission, you only need to
handle the translation ("position" value); you can safely assume that
the rotation parameter will always be (0,0,0) and the
scaling with always be (1,1,1). Handling rotation and scale parameters is an
extra credit work.
Grading Criteria
Your program must:
Submission
Please submit your code
along with your Makefile to your hand-in directory.
Fill in the writeup.txt which explain what you have
completed, what problems you have encountered and how you solved them, and a
description of your extra credit work. Also make a sub-directory called scenes,
and images, and place your representative scene-related files, and TIFF
snapshots into the respective sub-directories. Your handin
folder is at '/afs/cs.cmu.edu/academic/class/15462-f08-users/<your_andrew_id>/assn3'.
The folder has already been created for you. When we run "make" in
this directory it should compile your program successfully. In this assignment
we shall be strict about this policy. An assignment that does not compile
successfully shall receive no points.
If you experience any
difficulty with the hand-in directory, please email a
tar.gz or tar.bz2 of your submission to one of the TAs. The time of submission will be determined by the
time the email arrives at the final mail server (i.e. MAILXX.ANDREW.CMU.EDU).
For scp/sftp users: since the handin
directory resides on SCS AFS network, your username on the directory is
actually "<username>@ANDREW.CMU.EDU", not just
"<username>". To transfer your submission to the handin directory, please scp/sftp as "<username>@ANDREW.CMU.EDU" via
weh5336-?.intro.cs.cmu.edu.
Tips
Competition
We have decided to have a competition this year, to award a
student with the “Best Ray-Tracer Award.” The TAs and the professor will
together decide which ray tracer is deserving of the award. The winner will
receive (apart from personal satisfaction), a copy of Spore for PC/Mac! (Or
some other game if the class decides otherwise).
Extras
Credits are given based
on the difficulty, technicality, and creativity. It will be harder to earn
extra credit in this assignment. Please list all of your extra work in the
writeup.txt file. The maximum assignment point you can earn is 115%. Here are
some suggestions for extra credit ideas:
Other cool things will
get extra credit as well (talk to the TAs before you actually implement it).
Links
[1] Starter
code
[2] Introduction
to Ray Tracing, Chapter 1 (CMU IPs only)
[3] Introduction
to Ray Tracing, Chapter 2 (CMU IPs only)
[4] Introduction
to Ray Tracing, Chapter 6 (CMU IPs only)
[5] Ray
Tracing Materials on SigGraph.org
[6] Cornell
box images by Henrik Wann
Jensen
[7] Internet Ray Tracing Competition
[8] Interactive
Ray Tracer
[9] The Brown
Mesh Set website