Project 2: Ray Tracing
Due: Tuesday, February 23, 2010
Checkpoint 1: Thursday, February 4, 2010; Checkpoint 2: Thursday, February 11, 2010
CSC385 - Computer Graphics
Goal: In this assignment you will implement a basic raytracer.
The program reads the description of a 3D scene from a
ray file and produces a rendered image of that scene. The program works in interactive and batch mode.
This assignment will be graded on a 100 point scale. The checkpoints are worth 5 points each. The late policy applies to the final deadline.
For motivation, a gallery of images created by previous semesters of this class at Harvey Mudd College is maintained here.
Action
The project is broken down into three parts, each taking about a week. At the end of the first and second parts
you'll run a series of tests to demonstrate you've implemented the required features.
We provide skeleton code, available on blackboard, that includes many support classes to help you get started. We also provide a solution executable to help you test and debug your code.
Part I: Ray Casting (40 points): In this part you'll build a simple ray casting system. Your program will cast rays into the scene and
find the closest intersecting object; i.e. triangle or sphere. You will also support scale, rotate, and translate
modeling transforms.
- (10 pts.) Cast rays into the scene:
Modify RayFile::raytrace() to generate rays from the
camera's position through each pixel of the image.
Review the UML diagrams to understand the RayFile class and how to
access the information needed to compute these rays.
-
(10 pts.)
Intersections with spheres: Modify Group::intersect() and
Sphere::intersect() to compute intersections between the ray and
a sphere.
Review the UML diagrams to understand the Group and Shape
classes. These hold the scene graph described by the input ray file.
Ignore group transforms for now.
(Test file: 1.sphere.ray.)
Information about the intersection point is passed using the _Intersection_
structure, which is described in intersection.h. The intersection routines
return the distance from the start of the ray to the interesection point.
Remember, you want to find the closest intersection point that is in front
of the camera!!
At this stage you can start to render images with white circles
by setting pixel (i,j) white if an intersection was found and black otherwise.
-
(5 pts.)
Intersections with triangles: Repeat the same step for triangles,
this time modifying Triangle::intersect().
(Test file:
2.triangle.ray)
- (10pts.) Transformations:
Now introduce transformations. Modify Group::intersect() to take into
account its local transformation. Use the transform information to convert the ray
into local coordinates, find the closest intersection, and use the
transform information to convert the intersection back into the parent node's coordinates.
Be careful when converting the normal!
Also, be sure to re-compute the distance to the intersection point
in the parent node's coordinates.
(Test file:
3.xfm.ray)
- (5 pts.)
Checkpoint 1:
One week after the project begins you'll be required to render 5 ray files to demonstrate your
ray casting capabilities.
Part II: Color (30 pts.): The next step is to compute the color at the intersection point.
- (2 pts.) Emissive:
Modify RayFile::getColor() to calculate color using the intersecting
surface's emissive properties.
(Test file: 4.emissive.ray)
- (3 pts.) Ambient:
Modify RayFile::getColor() to calculate color using the intersecting surface's
ambient properties and the ambient light in the scene.
(Test file: 5.ambient.ray)
- (7 pts.) Directional Lights: Implement
DirectionalLight::getDiffuse(), DirectionalLight::getSpecular(), and
DirectionalLight::getShadow() to calculate the effect of directional
lights on the scene.
Modify RayFile::getColor() to call these functions.
Note: make sure this works before moving on the more complicated
lights.
(Test file: 6.dirLight.ray)
- (8 pts.) Point Lights: Implement PointLight::getDiffuse(),
Point::getSpecular(), and PointLight::getShadow() to calculate the
effect of point lights on the scene.
Modify RayFile::getColor() to call these functions. Note: make sure
this works before moving on to spotlights.
(Test file: 7.pointLight.ray)
- (5 pts.) Texture mapping: Add texture mapping. Modify Triangle::intersect() and
Sphere::intersect() to calculate texture coordinates at the point of
intersection. Modify RayFile::getColor() to use the texture
color as the diffuse factor in the color calculation. Add getTexture(u,v) to the material class.
Use bilinear interpolation for the texture samples.
(Test files: textures.ray,
texture file)
- (5) Checkpoint 2:
Two weeks after the project begins you'll be required to render 5 ray files to demonstrate your
lighting/texturing capabilities.
Part III: Recursive Ray Casting (25 points): Next you'll extend your system to recursively cast rays
- (10) Reflection: Modify RayFile::getColor() to recursively
cast reflected rays at the point of intersection and then use this value
in the color calculation. Be careful to offset the reflected ray slightly,
so you don't re-discover the same intersection point.
(Test file: 9.reflect.ray)
- (10) Transmission Modify RayFile::getColor() to recursively
cast transmitted rays at the point of intersection and then use this value
in the color calculation. For now, ignore the refractive index.
- (5) Snell's Law : Modify RayFile::getColor() to use the index of
refraction and Snell's Law to calculate the correct direction of
transmitted rays through objects.
(Test file: 11.refract.ray)
Extensions (min 5 points) : Following are list of possible extensions to your ray tracer. Add at least one optional feature.
- (5) Bump Mapping: Add bump mapping.Modify Triangle::intersect() and Sphere::intersect() to compute to fill in the bumpNormal structure of the material at the point of intersection.
- (5) Spot Lights: Implement SpotLight::getDiffuse(),
SpotLight::getSpecular(), and SpotLight::getShadow() to calculate the
effect of spotlights on the scene.
Modify RayFile::getColor() to call these functions. (Test file: 8.spot.ray)
- (10) Procedural Textures - add support for 3D procedural
textures. Check out this
website for information on Perlin Noise.
- (5) Jittering - implement a jittered supersampling technique to reduce
aliasing by casting multiple rays per pixel, randomly jittered about the
center of the pixel, and averaging the colors.
- (5) Soft Shadows - treat each point and spot light as having some
finite volume and cast multiple rays for shadow tests. Modify
PointLight::getShadow() and SpotLight::getShadow() to return doubles
instead of booleans, and to return the average of these multiple shadow
tests. If you want, you can modify DirectionalLight:getShadow() to behave
similarly, but because a directional light doesn't have a position, good
results can be difficult to get.
- (5) Box Primitive - add support for a Box primitive
- (5) Cylinder Primitive - add support for a Cylinder primitive
- (5) Cone Primitive - add support for a Cone primitive
- (10) Torus Primitive - add support for a Torus primitive
Hard!
- (5) Depth of Field - implement depth of field camera effects
- (5) Fisheye Lens - implement fisheye lens camera effects
- (10) Bounding Boxes - speed up raytracing by implementing bounding
boxes. Create a bounding box class and modify each object so it knows
about its own bounding box for intersection testing.
- (?) Impress us with something we hadn't considered
- (5 max) Submit an entry to the art contest.
Create an interesting model and ray trace it with your program.
(The operative word is interesting!)
You must submit the model to receive point.
Notes
-
Visit the POVRAY site, home of a popular freeware raytracer. Check out the
links to the still
competitions and animated competitions for
inspiration..
- The rt Manual, UML diagrams for the support code, and description of the RAY file format are available on blackboard.
Deliverables
You should upload a zipped folder on blackboard that contains:
- your Visual Studio project folder for rt.
- an html writeup called "assignment2.html" that describes all features (or contest entries) you've implemented.
- all images you are submitting and their ray files (please link them to your html writeup) .
Make sure the source code compiles and runs on the Olin 102 PCs. If it doesn't, I will not be able to grade your submission and it will not receive any points!
Remember our standing late policy and collaboration policy.
You may submit a project worth more than 100 however after 100 points, each point is divided by 2, after 110 points, each points is divided by 4, etc.