6.837 Intro to Computer Graphics
Assignment 1: Ray Casting

In this assignment, you will implement a basic ray caster. This will be the basis of many future assignments, so proper code design is quite important. As seen in class, a ray caster sends a ray for each pixel and intersects it with all the objects in the scene. You will implement a ray caster for an orthographic camera (parallel rays) for sphere primitives. You will use a very basic shading model: the objects have a constant color. You will also implement a visualization mode to display the distance t of each pixel to the camera.

You will use object-oriented design to make your ray-caster flexible and extendable. A generic Object3D class will serve as the parent class for all 3D primitives. You will derive subclasses, such as Sphere, to implement specialized primitives. In later assignments, you will extend the set of primitives with planes and polygons. Similarly, this assignment requires the implementation of a general Camera class and an OrthographicCamera subclass. In the next assignment, you will also derive a general perspective camera.

We provide you with a Ray class and a Hit class to manipulate camera rays and their intersection points, and a skeleton Material class.

Tasks

Ray, Hit & Material Classes

We provide the Ray, Hit & Material classes. A Ray is represented by its origin and direction vectors. The Hit class stores information about the closest intersection point, the value of the ray parameter t and a pointer to the Material of the object at the intersection. The Hit data structure must be initialized with a very large t value. It is modified by the intersection computation to store the new closest t and the Material of intersected object. For this assignment a Material stores just the diffuse color of the object. You will extend this class in future assignments.

Parsing command line arguments & input files

Your program should take a number of command line arguments to specify the input file, output image size and output file. Make sure the examples below work, as this is how we will test your program. A simple scene file parser for this assignment is provided. The OrthographicCamera, Group and Sphere constructors and the Group::addObject method you will write are called from the parser. Look in the scene_parser.C file for details. If you're interested, here's the scene description file grammar used in this assignment.

Hints

Additional References

Input Files

Makefile for g++ on LINUX

Sample Results

raytracer -input scene1_01.txt -size 200 200 -output output1_01.tga -depth 9 10 depth1_01.tga

raytracer -input scene1_02.txt -size 200 200 -output output1_02.tga -depth 8 12 depth1_02.tga

raytracer -input scene1_03.txt -size 200 200 -output output1_03.tga -depth 8 12 depth1_03.tga

raytracer -input scene1_04.txt -size 200 200 -output output1_04.tga -depth 12 17 depth1_04.tga

raytracer -input scene1_05.txt -size 200 200 -output output1_05.tga -depth 14.5 19.5 depth1_05.tga

raytracer -input scene1_06.txt -size 200 200 -output output1_06.tga -depth 3 7 depth1_06.tga

raytracer -input scene1_07.txt -size 200 200 -output output1_07.tga -depth -2 2 depth1_07.tga

See the main Assignments Page for submission information.