**REJOICE*** Your code is due for submission by now... However,
some MASSIVE .ray files have been put together for your Art Contest submissions.
Such submissions are due by 11:59pm on Wed. Look in /u/cs426/3/rayfiles/
for these triangle intensive files. Provided are some 3D Studio Max
files (ported to .iv and then .ray) of a tricycle in a room, chess boards,
and a castle/temple. Also provided are the previous files: a seashell (like
you'll produce in the next assignment), and a texture mapping excersize.
You are strongly urged to attemp the rendering of these files, but don't
wait too long, as they'll take a long time to complete.
A conversion utility between Inventor (.iv) and our format (.ray) has been
created. It can be found in /u/cs426/3/ivtoray/, and runs only on SGI systems
(e.g. elmo). There are some sample .iv files in /u/cs426/3/ivfiles/
which have already been converted into .ray files in /u/cs426/3/rayfiles/.
Try raytracing these two new .ray files!!! Check your E-Mail for details...
Some OpenGL implementations DON'T like massive display lists, so an updated
version of rayview is available at /u/cs426/3/rayview.debug/. Running
this version with the -debug 1 option will force drawing into realtime,
avoiding the problems some GL systems (i.e. Exceed) have with 'large' .ray
files. Your raytracer, though, should not have trouble with 'large' files.
Check your E-Mail for further details...
Please check out the pu.cs.426
newsgroup to find out about a few bugs that people have found.
Two typos in precept notes have been corrected: The 'brute force' intersection
pseudo code, and the 2D texture coordinate mapping. See the hints section
for the link.
To prevent a bug in parser.c, the vector/matrix algebra routines have been
modified. A new raydata.h is available (see note below!).
A program to view .ray files in OpenGL is available in /u/cs426/3/rayview/.
NOTE: Don't mix the source code of the ray tracer (in /u/cs426/3/) with
the code for rayview, despite some of the source files havining identical
names. The unix build must be compiled and run on an SGI. Run
the program without cmd line options to see a usage summary.
The NT makefile for rayview is now available.
Assignment 3: Ray Tracing
Due: 11/8/99 at 8:00AM.
In this assignment you will implement a basic raytracer. To allow
you to focus on the nuts and bolts of the actual ray tracing, you are provided
with a host of data structures for managing the ray traced objects, linear
algebra functions (vector and matrix objects and operations), a function
for loading scene graph files into a prescribed node tree stucture, a BMP
image file importer/exporter (for images and textures, etc), and a couple
of supporting data structures for lights, materials, etc.
Samples of last years projects are available here.
Some of the links are broken, but at least half of them contain some nice
What You Have to Do
It would be a good idea to use the recursive approach outlined in the handout,
as your starting code is already organized in a similar fashion. You will
notice that it is in essence an object oriented solution using C.
If you wish, you could port this naturally to C++, but this is not required.
link leads to a detailed description of the file format. The node tree
and supporting structures into which it is parsed are described in the
source files and will be discussed in precept.
The assignment is worth 15 points. The following is a list of features
that you may implement. The number in parentheses corresponds to how many
points it is worth. Options in bold are mandatory.
By implementing all the required features, you get 10 points. There are
many ways to get more points:
(1) Generate and cast rays from the camera's position through pixels
to construct an image of the scene.
(1) Intersect a ray with a sphere to find the intersection point
and normal (see the handout).
(1) Intersect a ray with a triangle to find the intersection point
and normal. You should use the barycentric coordinate method to produce
the normal at the intersection point. (See the hints section)
(1) Perform a direct illumination calculation for each ray intersection
based on the Phong reflectance model used in OpenGL (ambient, emission,
(1) Support the directional, point, and spot lights sources used
(1) Support shadows by casting rays from object intersection points
to light sources to check for occlusions.
(1) Cast rays recursively along paths of specular reflection rays
to support reflective surfaces.
(1) Cast rays recursively along paths of "straight-through" transmission
to support translucent surfaces (without refraction).
(1) Implement two command line arguments that specify the maximum
recursion depth and minimum contribution factor cut-off threshold.
(1) Transform rays in your ray-scene intersection function(s) according
to the hierarchy of transformations present in the scene graph structure.
(1) Implement a jittered supersampling scheme to reduce aliasing by casting
multiple rays per pixel, randomly jittered about pixel centers, and averaging
the radiance samples.
(1) Use the index of refraction and Snell's Law to calculate the correct
direction of rays trasmitted through transparent surfaces. You can assume
that all scene objects are closed solids....
(2) Treat positional lights as having a finite 'area' and cast a collection
of rays during shadow checking to generate soft shadows. That is,
if all shadows rays are blocked or unblocked we have zero or full lighting
from the source in question just as before, but if a fraction of the shadow
rays are blocked the light is only partially attentuated. Something
randomized and/or adaptive scheme should be used to avoid banding.
(1) The ability to ray trace cubes (the length, width and height are given
and not necessarily equal).
(2) The ability to ray trace cones and cylinders (which have end caps).
(2) Accelerate ray intersection tests with hierarchical bounding volumes.
(3) Accelerate ray intersections with grid, octree or BSP spatial data
(2) Texture mapping image files onto triangles. Find texture coordinates
at the intersection point by interpolating the given texture coordinates
at the vertices using the barycentric coordinates.
(2) Procedural texture mapping with Perlin
noise functions to create 3-D solid wood, marble, etc.
(1) Bump mapping for either or both texturing schemes.
(1) Depth of field camera effects.
(2) Simulate real camera lens behaviour. You must implement the procedure
in this SIGGRAPH
(2) Open a window that displays a progressive view of the the ray tracing
in realtime. The image should initially be of very low resolution and become
sharper over time.
(2) Add a mode with opens a window and ray traces the image by casting
rays from a region about the location of the user's mouse pointer.
It should appear as if the user is airbrushing the image into existence.
(?) Impress us with something we hadn't considered...
It is possible to get more than 15 points. However, after 15 points, each
point is divided by 2, and after 17 points, each point is divided by 4.
implementing optional features (as listed above),
submitting 3D models you constructed (1),
submitting images for the art contest (1), and
winning the art contest (1).
You should use the code available at /u/cs426/3/, on the MECA
machines, as a starting point for your assignment. We provide you with:
After you copy the provided files to your directory, the first thing to
do is compile the program. If you are developing on a Windows NT machine,
running Microsoft Visual C++, from the MS-DOS prompt, type:
main.c - This parses the command line, calls to the ray trace function
in ray.c, and saves the results to a .BMP file.
bmp(.c)(.h) - Contains the Image data structure and functions for loading
and saving .BMP files to and from them.
parser(.c)(.h) - A library call for loading a .ray file and parsing it
into our ray tracing data structures for cameras, lights, materials, and
textures, as well as the object node tree, which contains all the shapes.
raydata.h - Contains descriptions of the the given data structures, and
an abstracted shape data structure interface.
cone,cube,cylinder,sphere,triangle(.c)(.h) - Specific implementations of
the abstract shape interface described in raydata.h. .
ray(.c)(.h) - The location for the main controlling code of the ray tracerer.
Makefile.nt A Makefile suitable for Windows NT platforms.
Makefile.unix: A Makefile suitable for UNIX platforms.
If you are developing on a UNIX machine, type:
% copy Makefile.nt Makefile
% "c:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32"
An executable called ray or ray.exe will be compiled and
% cp Makefile.unix Makefile
What to Submit
You should submit:
The writeup should be a HTML document called assignment3.html
which may include other documents or pictures. It should be brief, describing
what you have implemented, what works and what doesn't, how you created
the art contest images, and any relavent instructions on how to run your
the complete source code with a Makefile,
any *.ray files you created
the images for the art contest, and
Make sure the source code compiles in the MECA
workstations. If it doesn't, you will have to attend to a grading session
with a TA, and your grade will suffer.
Always remember the late
policy and the collaboration
Stay tuned for more hints.
Pay careful attention to this quote:
Stay tuned for more questions.
Last update: 10/27/99