Your program will support two primitives: spheres and triangles. You'll have a simple material model and a handful of lights. In order to get complete credit, a number of possible extensions and their various point values are specified below.
Your program will take its input in a simple ASCII format (which, conveniently, is parsable by Tcl) and will generate its output as PPM "raw" image files (click here for the PPM specification).
Ray tracers are very, very modular programs. If you start early, you can design a system where you can add features as you go. You may want to seriously consider using an object-oriented programming style (either in C or C++).
Ray tracers can be extremely small programs, too. Check out Paul Heckbert's ray tracer on the back of a business card.
Ray tracers generate really beautiful pictures. Check out The Raytracing Competition for some inspiration.
A number of sample scenes will eventually be available in the cs426 class directory. Stay tuned.
camera_from x y z
camera_target x y z
camera_forw x y z
camera_up x y z
camera_angle theta
camera_resolution x y
max_vertices n
max_normals n
vertex x y z
normal x y z
You may find it useful for the vertex and normal commands to return their index numbers back to Tcl.
tri v1 v2 v3
ntri v1 n1 v2 n2 v3 n3
Note: the arguments passed to tri and ntri are indices into the vertex and normal pools.
sphere x y z radius
background r g b
ambient_light r g b
parallel_light r g b x y z
point_light r g b x y z
spot_light r g b px py pz nx ny nz angle1 angle2
material r g b Ka Kd Ks n_s T index_of_refraction
Ka is the ambient component, Kd is the diffuse component, Ks the specular, n_s is the Phong cosine power for highlights, T is transmittance (fraction of contribution of the transmitting ray). Usually, 0 <= Ka <= 1, 0 <= Kd <= 1, and 0 <= Ks <= 1, though it is not required that Ka + Kd + Ks == 1. Note that transmitting objects (T > 0) are considered to have two sides for algorithms that need these (normally objects have one side). Also note that you can use Ks to define the contribution of a reflected ray.
The fill color is used to color the objects following it until a new color is assigned.
For the assignment, you're required to deal with neither transparent nor reflective objects. It's optional. See the Grading section, below.
render file.ppm
You should be able to view your images with xv, where you can convert them to any other format, such as GIF and JPEG for your personal Web pages.
clear_scene
trace_depth n
Pay very careful attention to this quote:
Novice programmers often neglect the design phase, instead diving into coding without giving thought to the evolution of a piece of software over time. The result is a haphazard, poorly modularized code which is difficult to maintain and modify. A few minutes of planning short-term and long-term goals at the beginning is time well spent.You should think very carefully about the structure of your system. You need to intersect rays with triangles, spheres, and possibly with your acceleration structures. You want some kind of generic object with function pointers to the intersection functions (C++ folks would use inheritance with virtual functions). Start early, and you've got plenty of time to finish. Start the night before, and you'll get nowhere.- Paul Heckbert, ``Writing a Ray Tracer,'' in An Introduction to Ray Tracing, edited by Andrew Glassner.
Assuming you implement your ray tracer using Tcl as an interface, you'll only need Tcl, not Tk. A side benefit is that you can run your program anywhere, not just an SGI. Ultimately, you should have a Tcl script which runs your ray tracer like so:
The simplest possible version of the "raytrace" script only really needs to say:raytrace teapot.tsd teapot.ppm
Although, you may wish to add additional functionality to your Tcl code, such as defining default values for the camera, the ambient light, etc.#!./rayshell source [lindex $argv 0] render [lindex $argv 1] exit
Note: you may want to think about continuing your ray tracer for your final project.
Feature | Value |
---|---|
Primitives | |
Cones and cylinders | 0.5 points |
Constructive solid geometry | 0.5 points |
Metaballs, splines, and other algebraic surfaces | 1.0 points |
Fractals or other recursively defined primitives, evaluated on-the-fly (usually tied into your acceleration structure) | 0.5 points |
Lighting | |
Spot lights | 0.5 points |
Area lights / soft shadows | 1.0 points |
Sampling | |
Jittered, filtered oversampling | 0.5 points |
Adaptive oversampling | 1.0 points |
Motion blur | 1.0 points |
Depth of field / real camera lenses | 1.0 points |
Materials | |
Texture and bump mapping (cylindrical, spherical, and planar projections) | 1.0 points |
Procedural textures (checkerboards, wood, marble, wavy water, etc.) | 1.0 points |
Displacement mapping | 1.0 points |
Miscellaneous | |
Good acceleration structures (hierarchical bounding volumes, spatial octrees, etc.) - if you're amazingly fast, you'll get more points | 1.0 points |
Reflections and transparency | 0.5 points |
Make a short MPEG movie of bouncing balls | 0.5 points |
Make a user interface which shows the ray tracing in progress | 0.5 points |
Spread out the samples so you see a coarse picture quickly | 0.5 points |
Parallelize your ray tracer (CS461 folks may want to do this on ACME) | 0.5 points |
In the process of implementing some of the extensions, you'll want to add new commands to the Tcl script to handle them. Please take the time to argue about them in the pu.cs.426 newsgroup so people may actually standardize on some of these extensions and be able to share input files.
Finally, also submit a URL (in your README) of your favourite image, created with your ray tracer. Maybe you can make it to look like this... (image created by Kevin Odhner).