CMSC 435/634: Introduction to Computer Graphics

Assignment 5
Enhanced Raytracing
Due December 3, 2010

The Assignment

For this assignment, you will add lighting to the ray tracer you implemented in assignment 2. The same input file format will be used to describe the scene, with additional commands included to support lighting (described below). The actual lighting calculation consists of multiple parts:

Re-Using Assignment 2 Code

You are expected to complete assignment 5 by modifying your code for assignment 2. If you did not complete assignment 2, or if you think you will be unable to modify your code, you can request a working implementation from the TA.

Sample Input Files

There are a few sample input files located at:

    /afs/umbc.edu/users/r/h/rheingan/pub/435/Proj5/samples
The files balls1.nff, balls2.nff, and balls3.nff are identical to the sample files from project 2, except that they include lighting commands. As before, the files correspond to different levels of recursion for fractally defined spheres.

Input File Format

As in project 2, the input file will use a subset of the NFF file format. You should support the commands below, in addition to the ones used in project 2 ("f" has been repeated since this assignment uses additional features of it).

l
Positional light.  A light is defined by XYZ position.  Description:
    "l" X Y Z [R G B]

Format:
    l %g %g %g [%g %g %g]

    All light entities must be defined before any objects are defined (this
    requirement is so that NFF files can be used by hidden surface machines).
    Lights have a non-zero intensity of no particular value, if not specified
    (i.e. the program can determine a useful intensity as desired); the
    red/green/blue color of the light can optionally be specified.
f
Fill color and shading parameters.  Description:
    "f" red green blue Kd Ks Shine T index_of_refraction

Format:
    f %g %g %g %g %g %g %g %g

    RGB is in terms of 0.0 to 1.0.

    Kd is the diffuse component, Ks the specular, Shine is the Phong cosine
    power for highlights, T is transmittance (fraction of contribution of the
    transmitting ray).  Usually, 0 <= Kd <= 1 and 0 <= Ks <= 1, though it is
    not required that 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).

    The fill color is used to color the objects following it until a new color
    is assigned.

Extra Credit (some mandatory for those taking 634)

Standard Procedural Database

More sample scenes in NFF format can be created using a set of programs called the "Standard Procedural Database", which is freely downloadable. A copy of the SPD is also located at:

    /afs/umbc.edu/users/r/h/rheingan/pub/435/Proj2/spd
The sample files listed above were created using the SPD program 'balls', which writes an NFF file to standard output. For example:
    balls -s 1 > balls1.nff
The -s option controls the level of recursion. Note that the output of the SPD programs typically includes NFF commands other than the ones required for this assignment (balls outputs a single polygon which was removed from the sample files). Therefore, if you want to test your ray tracer using the SPD programs, you should be able to handle the presence of such commands in your input file (you should simply ignore any commands you do not implement).

The program 'shells' outputs many spheres, similarly to balls; 'lattice' and 'jacks' output cylinders and cones, 'tetra' and 'teapot' output primarily convex polygons, and 'gears' includes concave polygons.

What To Turn In

Submit your assignment as 'Proj5'. Include your source code and makefile. Please do not submit PPM files, as they can be very large. If you must submit images, convert them to a compressed format such as .jpeg. The 'convert' program is available on the GL servers, so for example you can do:

    convert image.ppm image.jpg

Also include a readme file with a description of what hardware / software environment you used to develop your project, and a description of any help you received or outside resources you used. (If you received no help beyond the text and course staff, state as much.) Your readme should also include any instructions necessary for using your program.

Working At Home

If possible, don't. We test things out on the university computers and may or may not be able to help you if things don't work right for you at home. If you do work at home, your final submitted version must be able to run on the gl machines and must be electronically submitted there.