Description

In this project, you will implement a basic ray tracer.

Code

Skeleton code is available here. This code contains a number of files, including.

The methods that you need to implement are marked with 'TODO' in the code. The TODO lines print out a simple message when executed to help you identify what functions need to be implemented and where they are located. A code skeleton and driver framework is provided. You will need to implement object intersections, shading, and ray casting.

To run the tests, run ./ray_tracer -i <test-file>, where test-file is one of the provided test files. More detailed usage instructions are provided in the main.cpp file. The tests are designed to be implemented and debugged in order and are intended to help you debug your implementation. They will also be used for grading.

The code contains many comments explaining what needs to be done and what functions should do. It is very highly recommended to to read through the code and comments before you begin implementing things. Being aware of the functions and variables that are available to you with help you write your code.

Submission Instructions

Please package up your code before you submit it (tar.gz, tar.bz2, or zip). Your submission should contain all of the source files that you modified (it is okay but unnecessary to submit files that you did not modify). You should not modify main.cpp (if you submit a copy of this file, it will be overwritten by the original). As a general rule, you should not modify files that do not contain a TODO.

Grading script

This project comes with a grading script, which you can run like this: "./grading-script.py .". Be sure to run this script before you submit your project (or checkpoint) to be sure that the program functions as you expect in grading mode. If you receive a grade that differs from what you saw from the grading script, let the instructor know.

Checkpoints

This project has two checkpoints. Checkpoints are intended to encourage you to start your project early. At each checkpoint, you will submit your project just as you would when it is due. At the first checkpoint, your program will be graded out of 20 points. At the second checkpoint, your program will be graded out of 35 points. No extra credit is possible at checkpoints. When your project is due, it will be graded out of 50 points, and extra credit will be given for scores higher than that. A maximum score of 60 is possible; the extra 10 points are extra credit.

Test cases

The table below documents the tests. Along with a thumbnail showing what the result should look like, I make some potentially helpful notes about the test case. Click the thumbnail for a full-size image.

Pixel traces

Some of the test cases come with a pixel trace. This trace provides detailed information about intermediate calculations that occured when calculating the color of one particular pixel in the image. The -x and -y options are provided to help you print out this information from your own implementation. Pixel traces allow you to identify the cause of a problem, which might otherwise be difficult to track down.

Thumbnail Notes
thumb-00.png 00.txt

5 points

pixel trace

Bare minimum to getting started: flat shading, sphere intersections, casting rays.
thumb-01.png 01.txt

5 points

Get the coordinate system oriented correctly, introduce colors.
thumb-02.png 02.txt

1 points

Test image size and camera settings.
thumb-03.png 03.txt

1 points

pixel trace

Test irregular camera orientation.
thumb-04.png 04.txt

3 points

Get basic plane intersections working.
thumb-05.png 05.txt

3 points

pixel trace

Add Phong shading (diffuse only) and handle point lights.
thumb-06.png 06.txt

1 points

pixel trace

Phong shading with sphere - diffuse only.
thumb-07.png 07.txt

1 points

Phong shading colored material and colored light. Diffuse only.
thumb-08.png 08.txt

1 points

pixel trace

Add specular.
thumb-09.png 09.txt

1 points

pixel trace

Both diffuse and specular.
thumb-10.png 10.txt

1 points

pixel trace

Move light off center; break symmetry.
thumb-11.png 11.txt

1 points

Colors with lights, diffuse, and specular.
thumb-12.png 12.txt

1 points

Phong shading with full scene.
thumb-13.png 13.txt

1 points

Add color to the lights; make sure things work with two lights.
thumb-14.png 14.txt

1 points

Add background shader, introduce ambient light.
thumb-15.png 15.txt

1 points

Shading test.
thumb-16.png 16.txt

1 points

Specular shading test - test exponent.
thumb-17.png 17.txt

1 points

Specular shading test - test exponent.
thumb-18.png 18.txt

1 points

Specular shading test - test exponent.
thumb-19.png 19.txt

1 points

Specular shading test - test exponent.
thumb-20.png 20.txt

2 points

pixel trace

Introduce basic shadows. This is also a bug test; there is a very bright light hidden under the ground.
thumb-21.png 21.txt

1 points

Bug test: objects behind the light.
thumb-22.png 22.txt

1 points

Bug test: object covering up the light. Since no light escapes, the image should only contain ambient light.
thumb-23.png 23.txt

1 points

pixel trace

Test recursion depth.
thumb-24.png 24.txt

1 points

Test recursion depth.
thumb-25.png 25.txt

1 points

pixel trace

Test recursion depth.
thumb-26.png 26.txt

1 points

pixel trace

Start implementing Booleans: basic union.
thumb-27.png 27.txt

1 points

Start implementing Booleans: basic intersection.
thumb-28.png 28.txt

1 points

pixel trace

Start implementing Booleans: basic difference. Check to make sure that complex objects can cast shadows on themselves.
thumb-29.png 29.txt

1 points

Handle nesting of Booleans.
thumb-30.png 30.txt

1 points

pixel trace

Bug test: check complex interaction of Booleans.
thumb-31.png 31.txt

1 points

pixel trace

Bug test: check complex interaction of Booleans.
thumb-32.png 32.txt

1 points

pixel trace

Bug test: check complex interaction of Booleans.
thumb-33.png 33.txt

1 points

pixel trace

Bug test: check complex interaction of Booleans.
thumb-34.png 34.txt

1 points

pixel trace

Bug test: check complex interaction of Booleans.
thumb-35.png 35.txt

1 points

pixel trace

Bug test: make sure degenerate cases are handled correctly. Union and intersection with duplicate objects is easy to deal with and should would correctly. Note that the difference of duplicate objects is somewhat ambiguous, so this case is not tested.
thumb-36.png 36.txt

1 points

Construct a bounded object from unbounded primitives.
thumb-37.png 37.txt

1 points

pixel trace

Complex Booleans and self-shadowing.
thumb-38.png 38.txt

1 points

pixel trace

Bug test: what happens if we construct a hollow piece of geometry and fill it with a camera, lights, and objects?
thumb-39.png 39.txt

1 points

pixel trace

Start implementing transforms. Translation only.
thumb-40.png 40.txt

1 points

pixel trace

Start implementing transforms. Rotation only.
thumb-41.png 41.txt

1 points

pixel trace

Start implementing transforms. Scale only.
thumb-42.png 42.txt

1 points

pixel trace

Make sure transforms can be combined correctly. Note that exactly the same transformation is being applied in two ways: as a series of separate transforms and combined within a single transform.
thumb-43.png 43.txt

1 points

pixel trace

Make sure transforms work correctly with booleans.
thumb-44.png 44.txt

1 points

pixel trace

Start implementing torus
thumb-45.png 45.txt

1 points

pixel trace

Make sure all of the parameters to torus work.
thumb-46.png 46.txt

1 points

pixel trace

Make sure torus works with booleans. This is also a bug test; the camera is inside the torus, but it is outside of the visible boolean object.