In this project, you will implement a basic ray tracer.
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. These can be found in camera.cpp, phong_shader.cpp, plane.cpp, reflective_shader.cpp, ref render_world.cpp, refractive_shader.cpp and sphere.cpp. 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 <test-file>
, where test-file is one of the provided test files.
The tests can also be run with ./ray_tracer_preview <test-file>
, in which case the result is rendered to the screen using OpenGL along with the solution (if available).
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. Be sure to read through the code and comments before you begin implementing things.
You will submit your code as one file in one of these formats: tar, tar.gz, tar.bz2, or zip. Your submission should contain:
Here are some ideas for extra credit:
You may also suggest another option by contacting the professor (by email or in office hours). In any case, you will need to explain briefly what you have done and how you did it (extra-notes.txt). The presence of extra-notes.txt indicates that extra credit has been done. For each file you add, briefly explain its purpose. For each file you modified, briefly explain why it was modified. Indicate which test cases are included, how to run them, and what we should see. No credit will be given for extra credit that is not demonstrated with at least two test cases, one of which should be nontrivial and challenging. Extra credit up to 10% of the total value of the project is possible. Changes made for extra credit should not alter the behavior of the original test cases.
We are providing you with a grading script that we will be using to grade this project.
You can run it like this: "./grading-script.py ./tests
".
There is a 15 second time limit on each test; this should be more than enough time for the tests provided.
Be sure to test your project on one of the delta machines.
Note that extra credit projects will vary from student to student and are not graded using the script (except for the Booleans). These will be graded individually.
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 12 points. No extra credit is possible at checkpoints. When your project is due, it will be graded out of 47 points, and extra credit will be given for scores higher than that.
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.
Thumbnail | Notes |
---|---|
00.txt 5 points pixel trace Bare minimum to getting started: flat shading, sphere intersections, casting rays. |
|
01.txt 5 points Get the coordinate system oriented correctly, introduce colors. |
|
02.txt 1 points Test image size and camera settings. |
|
03.txt 1 points pixel trace Test irregular camera orientation. |
|
04.txt 1 points Get basic plane intersections working. |
|
05.txt 1 points pixel trace Add Phong shading (diffuse only) and handle point lights. |
|
06.txt 1 points pixel trace Phong shading with sphere - diffuse only. |
|
07.txt 1 points Phong shading colored material and colored light. Diffuse only. |
|
08.txt 1 points pixel trace Add specular. |
|
09.txt 1 points pixel trace Both diffuse and specular. |
|
10.txt 1 points pixel trace Move light off center; break symmetry. |
|
11.txt 1 points Colors with lights, diffuse, and specular. |
|
12.txt 1 points Phong shading with full scene. |
|
13.txt 1 points Add color to the lights; make sure things work with two lights. |
|
14.txt 1 points Add background shader, introduce ambient light. |
|
15.txt 1 points Shading test. |
|
16.txt 1 points Specular shading test - test exponent. |
|
17.txt 1 points Specular shading test - test exponent. |
|
18.txt 1 points Specular shading test - test exponent. |
|
19.txt 1 points Specular shading test - test exponent. |
|
20.txt 5 points pixel trace Introduce basic shadows. This is also a bug test; there is a very bright light hidden under the ground. |
|
21.txt 1 points Bug test: objects behind the light. |
|
22.txt 1 points Bug test: object covering up the light. Since no light escapes, the image should only contain ambient light. |
|
23.txt 1 points pixel trace Test recursion depth. |
|
24.txt 1 points Test recursion depth. |
|
25.txt 1 points Test recursion depth. |
|
26.txt 1 points Start implementing refractive shader: Reflection only test. Cast a reflective ray in refractive shader (almost same with the reflective shader). |
|
27.txt 1 points Refraction only test. Compute and cast the refracted ray. You do not have to consider computing the reflectance ratio yet. |
|
28.txt 1 points Blending reflection and refraction components. Update/compute the reflectance ratio. |
|
29.txt 1 points Testing with different refraction indices. |
|
30.txt 1 points The transition of reflection to refraction is tested with a striped pattern. The scene with the middle plane rendered with different shaders is available here |
|
31.txt 1 points Testing interaction of refractive_shader and reflective_shader with high recursion depth. |
|
32.txt 3 points Final test: A number of objects with various shaders are thrown in a room. |
Below are the extra credit Boolean tests.
Thumbnail | Notes |
---|---|
33.txt 1 points pixel trace Start implementing Booleans: basic union. |
|
34.txt 1 points Start implementing Booleans: basic intersection. |
|
35.txt 1 points pixel trace Start implementing Booleans: basic difference. Check to make sure that complex objects can cast shadows on themselves. |
|
36.txt 1 points Handle nesting of Booleans. |
|
37.txt 1 points pixel trace Bug test: check complex interaction of Booleans. |
|
38.txt 1 points pixel trace Bug test: check complex interaction of Booleans. |
|
39.txt 1 points pixel trace Bug test: check complex interaction of Booleans. |
|
40.txt 1 points pixel trace Bug test: check complex interaction of Booleans. |
|
41.txt 1 points pixel trace Bug test: check complex interaction of Booleans. |
|
42.txt 1 points Construct a bounded object from unbounded primitives. |
|
43.txt 1 points pixel trace Complex Booleans and self-shadowing. |
|
44.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? |