Comp 360 Lab 3 : Rendering Scenes with Ray Tracing

1  Overview

In this project you will implement a static ray tracer for scenes containing primitive 3-dimensional objects, including spheres, ellipsoids, boxes, cylinders, and cones. Your renderer will support multiple light sources, object shadows, reflection, refraction, and transparency. Additionally, you will create at least four interesting 3-dimensional scenes and render these scenes with your ray tracer.

2  Specification

We will provide you with a framework upon which you can build your project. By default, the program will load in a scene file called "default.ray" and render a polygonal representation of the scene. You can modify this scene using controls as described in the "Program Controls" section. Once you are satisfied with the scene, you can ray trace the scene by pressing a button (F5). Another window will pop-up, and it will progressively ray trace the scene.
The basic framework contains only the ability to parse and ray trace a sphere without shading. You will need to rewrite the sphere intersection code using the algorithm in the text book. You will fill out the rest of the code for ray tracing other objects. You will also write a few user-interface/applicational enhancements to the given framework.

2.1  First Milestone (1 Weeks, 11/15/2010, 11:59pm)

By the first milestone deadline, your program must do the following:

2.2  Second Milestone (1 Weeks, 11/22/2010, 11:59pm)

By the second milestone deadline, your program must do the following:

2.3  Final Submission (1.5 Weeks, 12/1/2010, 11:59pm)

By the final project deadline, in addition to the requirements for the first milestone, your program must do the following:

2.4  Sample Files / Pretty Pictures

Your final submission should contain at least 4 scene files of your own creation. Be creative. Your files should demonstrate all the various ray tracing effects and all the object types. For each scene file you create, please include a picture file in the bmp format that contains your renderer's output for that scene.

2.5  Extra Credit

3  Program Controls

Using the given framework will require familiarity with the following controls. You may add or change the controls as you wish. Document your changes in your README file.

Viewing Mode

Change the camera orientation and position.

Selection Mode

Select an object in the scene for manipulation.

Editing Mode

Edit an object's definition and position.

Application Controls

4  Suggested Plan

The following is a short outline that describes a suggested plan of attack. If you accomplish each of these tasks in a day or two, you should have ample time to complete this project.

4.1  First Milestone

4.2  Second Milestone

4.3  Final Submission

After the first milestone, you should have the majority of the functionality of the ray tracer. The only remaining tasks are computing normals to the other surfaces and computing intersection points between the other surfaces and rays. Pseudo-code for these computations are provided in the text book.

4.4  Implementation Notes

5  What To Turn In

Create the directory lab3. This directory should contain your source code and all files needed to build your program. Also include a README file containing:
Zip up this folder and follow the instruction on the course web page for submission.

5.1  Turning In First/Second Milestone

Please follow the same submission directions as above when you complete the First and Second Milestones. The README for the milestone requires only your names and a list of the features your milestone code supports.

6  Scene File Format

A lab 3 scene file is an ASCII text file containing data that define lighting and geometry for a ray traced scene. A scene file is organized into two parts, lighting attributes and object definitions. Lighting attributes are always given first.
In a scene file, values are separated by one or more blank spaces. Scene files support C++-style double-backslash (//) comments- the double backslash characters mean that input should be ignored until the next newline character. An example file appears at the end of this document.

6.1  Lighting Attributes

The lighting of the scene appears in the following sequence.
  1. The scene's ambient light color. (Three floating point values).
  2. The number of point light sources in the scene - at least 1. (One integer).
  3. For each point light source
    1. The light's position in space. (Three floating point values).
    2. The light's color. (Three floating point values).

6.2  Object Definitions

Beneath the lighting attributes, the input file will contain at least one object definition. Object definitions are given with the following sequence.
  1. The number of objects in the scene - at least 1. (One integer).
  2. For each object
    1. The object's type, one of the string "sphere", "ellipsoid", "box", "cone", or "cylinder".
    2. A set of numbers defining the object's geometry- format varies, see below.
    3. A set of numbers defining the object's material properties. This format is the same for all objects.
The object definition formats are as follows.

Sphere

A sphere is defined by the following values.
  1. The coordinates of the center of the sphere. (Three floating point values).
  2. Radius of the sphere (One floating point value).

Ellipsoid

An ellipsoid is defined by the following values.
  1. The coordinates of the center of the ellipsoid. (Three floating point values).
  2. Unit vector in the direction of the ellipsoid's first axis, v1. (Three floating point values).
  3. Unit vector in the direction of the ellipsoid's second axis, v2. (Three floating point values). Dot product of v1 and v2 should be zero.
  4. Unit vector in the direction of the ellipsoid's third axis, v3. (Three floating point values). v3 should be the cross product of v1 and v2.
  5. Length of ellipsoid along v1 (One floating point value).
  6. Length of ellipsoid along v2 (One floating point value).
  7. Length of ellipsoid along v3 (One floating point value).
Note that if all axis lengths are equal, the result is a sphere.

Box

A box is defined by the following values.
  1. The coordinates of a corner of the box. (Three floating point values).
  2. Unit vector in the direction of the box's length, vl. (Three floating point values).
  3. Unit vector in the direction of the box's width, vw. (Three floating point values). Dot product of vl and vw should be zero.
  4. Unit vector in the direction of the box's height, vh. (Three floating point values). vh should be the cross product of vl and vw.
  5. Length of box (One floating point value).
  6. Width of box (One floating point value).
  7. Height of box (One floating point value).
The box should be drawn on the positive side of its corner as measured by the coordinate space given by the vectors vl, vw, and vh. Note that if length = width = height, the result is a cube.

Cylinder

An elliptical cylinder is defined by the following values.
  1. The coordinates of the center of the base of the cylinder. (Three floating point values).
  2. Unit vector along of the first axis of the ellipse that forms the cylinder's base. (Three floating point values).
  3. Unit vector along the second axis of this ellipse. (Three floating point values). Dot product of this vector and the vector along the first axis should be 0.
  4. Unit vector in the direction cylinder's central axis. (Three floating point values). This vector should be the cross product of the first two vectors. The cylinder grows up from its base along the axis vector.
  5. Length of the first axis of the cylinder's elliptical base (One floating point value).
  6. Length of the second axis of the cylinder's elliptical base (One floating point value).
  7. Height of the cylinder along its axis (One floating point value).

Cone

A cone is defined by the following values.
  1. The coordinates of the center of the base of the cone. (Three floating point values).
  2. Unit vector along of the first axis of the ellipse that forms the cone's base. (Three floating point values).
  3. Unit vector along the second axis of this ellipse. (Three floating point values). Dot product of this vector and the vector along the first axis should be 0.
  4. Unit vector in the direction cone's central axis. (Three floating point values).
  5. Length of the first axis of the cone's elliptical base (One floating point value).
  6. Length of the second axis of the cone's elliptical base (One floating point value).
  7. Height of the cone along the axis (the distance from the center of the cone's base to the vertex of the cone). (One floating point value).

Material Properties

Immediately after the definition of an object's geometry, its material properties are given as follows.
  1. The object's ambient coefficient. (Three floating point values between 0 and 1).
  2. The object's diffuse coefficient. (Three floating point values between 0 and 1).
  3. The object's specular coefficient. (Three floating point values between 0 and 1).
  4. The object's specular exponent. (One floating point value).
  5. The object's reflective coefficient. (One floating point value between 0 and 1).
  6. The object's transparency coefficient. (One floating point value between 0 and 1).
  7. The object's index of refraction. (One floating point value).

Sample File

// Lighting
1 1 1     // R, G, B of ambient color
1         // Number of light sources
0 5 5   // x, y, z position of the first light source
1 1 1     // Color of the first light source

// Objects
2 // Number of objects

// First object
sphere         // Type
0 0 0          // x, y, z coordinates of center of the sphere
1.5            // radius of the sphere
0.1 0.1 0.1    // Ambient coefficient
0.45 0.45 0.45 // Diffuse coefficient
0.5 0.5 0.5    // Specular coefficient
5              // Specular exponent
0.5            // Reflection coefficient
0.1            // Transparency coefficient
1.6            // Index of refraction

// Second object
box            // Type
0 0 0          // x, y, z coordinates of corner of box
1 0 0          // Normalized vector of the direction of Length (vl)
0 1 0          // Normalized vector of the direction of Width (vw).
               // (Dot product of vl and vw should be zero.)
0 0 1          // Normalized vector of the direction of Height (vh).
               // (vh should be the cross product of vl and vw.)
.5 .5 1         // The Length, Width, and Height of the box, in floats.
0.1 0.1 0.1    // Ambient coefficient
0.45 0.45 0.45 // Diffuse coefficient
0.5 0.5 0.5    // Specular coefficient
5              // Specular exponent
0.5            // Reflection coefficient
0.1            // Transparency coefficient
1.1            // Index of refraction




File translated from TEX by TTH, version 3.89.
On 09 Nov 2010, 11:24.