Computer Science Department

CS510

Computer Graphics

Spring 1999


 Ray Tracing Lab.

 Due Tuesday Feburary 23rd, 1999

Introduction

In this lab you are to build a simple ray tracing program which will create imagery similar to that shown at the top of this page. In fact, the caged cube will be your test model. You will be given two ASCII file formats, one for the file which describes the object being viewed and the other all of the viewing parameters required to create a ray-traced image. You will be asked to do create a program, written in C or C++, that reads these two files and produces a single image file as output. Optionally, a GUI tool will be made available to you which you can use to build an interactive program. To emphasize, the batch version of this program is what will be required. The interactive version is something you may want to pursue on your own.

Your program will be expected to do reflection. You will not be required to do refraction. That is one way in which your program will be less powerful than the one illustrated above. In the cube above, the sphere is transparent: i.e. rays are refracting through it.

Object Model File Format

The 3D object model consists of both polygonal faces and spheres. There are three files provided for you in this lab. There are in what is informally called "CS510 format". This is an output option for STOMP if you wish to create other models: recall though that stomp will not generate true spheres. The three files to use in this assignment are:

The files are divied into three parsts: vertices, polygon faces and spheres. Part 1 specifies the 3D vertices used by both the polygons and the spheres. The first number is the vertex count. The next count lines in the file provide the x, y and z coordinates of the vertex. Part 2 begins with a new line containing the number of polygonal faces. This line is then followed by two lines per face. Finally, part 3 begins with the number of spheres. There are then two lines for each sphere. Here is a copy of the simplest file: planeTest.scene

 4
-2 -2 0
-2 2 0
2 2 0
2 -2 0
1
4
255 255 255
3 2 1 0
0
number of vertices
vertex one
vertex two
vertex three
vertex four
number of faces
number of vertices per face
color of face material
vertices
number of spheres

Look at the other files to see how more complex models appear.

Viewing Parameters File Format

The viewing parameters files contain specification for the scene lighting and camera model. There is one view file per scene:

Here is the view file for the planeTest example annotated:

VRP 0 4 10
lookat 0 0 0
VUP 0 1 0
PRP 0 0 7
window -1 -1 1 1
pixels 255 255
light1 1 0.3 2 255 0 0
light2 -1 0.3 2 0 255 0
light3 0 -1.7 2 0 0 255
ambient 255 255 255
ics 0.2 0.5 0.6
fatt 0.1 1.0 1.0 0.0
View reference point in world coordinates
Lookat point in world coordinates
Up vector in world coordinates
Perspective reference point in camera coordinates
Bounds of image window in camera coordinates
Pixel sampling size: width and height
Light source one
Light source two
Light source three
Ambient light strength and color
The ambient, diffuse and specular constants
The distance attenuation, scale and three terms

Where appropriate, you may want to consider defaults for these so they can be ommitted from files. Also, there are three others for which you must have defaults. These are:

phong 8
recursion 1
shadows 1
The exponent for Phong Illumination
Depth of recursion for rays tracing
Boolean to switch on and off shadows.

Examples of how these scens should appear are given at the end of this assignment.

Output Images

The resulting image should be written to a file. The deafult name should be "lab01.ppm". This file should be in PPM format. This format is described well at the The Graphics File Formats Page (search the page for PBM). This format is read by xv, so that you should have no difficulty displaying images. There is also a CS510 GUI tool which you may use at your option. If you wish to do this, speak with the instructor.

Approach

The approach you should take is that set forth in the lecture notes. Your ray tracer should do recursive ray tracing through pixel centers. The depth of the recursion is set in the view file. You should also implement a simple adaptive over sampling scheme as discussed in lecture. There should be a parameter and/or a flag in the view file to determine whether to do oversampling. You should do shadow tests when specified by the flag in the view file. The material properties for both diffuse and specular reflection are the same.

Deliverable

You should submit a complete system which takes the names of the view and scene files as arg 1 and 2 and produces the ray traced image. The third argument, optional, should be the name of the output image. You must submit f your code, lirbaries, etc. In other words, to run your program should require only that the instructor run make in the directory where your system is unpacked. Your code should produce imagery nearly identical to hat shown below for the test cases.

You should also include a scene of your own design. Include a corresponding view parameters file. For consistency, call this mine.view and mine.scene.

You will be graded upon the success of your program and on the quality of the code. In particular, the instructor will be looking for commented code.

Example Scenes

Here are examples of how each of the three scenes should appear:

planeTest

houseTest

cagedSphere

 


CS510 Home

Copyright © 1998 J. Ross Beveridge