Motivation (Update 11/12/19)

In the first assignment, you wrote code to read and manipulate 3D models in .obj format. In the second assignment, you wrote code to ray trace spheres with ambient and diffuse lighting. In this assignment, you will combine those and implement three more features in your ray tracer:

  • "mirror-like" reflection from models and spheres;
  • objects occluding light sources from reaching other objects, i.e. shadows;
  • specular highlights to further improve the realism of our lighting model.

Data Formats

The driver files used for this assignment are the same as in previous assignments with the following modifications:

  • There will now be a line specifying the recursion depth, e.g. recursionlevel 3. As in the SageMath notebooks, a recursion level of zero corresponds to no recursive ray tracing, like the second assignment.
  • We previously did not use the Ks and Kr values for spheres, but we will now. Ks is the amount that specular light should be attenuated. Kr is the amount that reflected rays should have their resulting color attenuated. The specular exponent for spheres will always be 16, as discussed in lecture.
  • In addition to spheres, models may be listed to render. They will have the same format as in the first assignment (model wx wy wz theta scale tx ty tz model.obj), and the same transformations must be done to transform the model's position into world coordinates.
  • Each .obj file will have a line mltlib file_name, where file_name is a .mtl file as described on Wikipedia and in lecture. The .obj file will also have lines such as usemtl shinyred that signify all faces after that line and before the next usemtl line should use the specified material in the .mtl file. For our purposes, we will currently only consider the Ka (ambient), Kd (diffuse), Ks (specular), Ns (specular exponent), and illum (illumination model) values. Ka, Kd, and Ks specify the reflectivity of the object for each kind of lighting, much as with spheres. Ns specifies the specular exponent, as discussed in lecture. The illum value is used for determining if a model is "mirror-like" in its reflection. The only illum values we will consider currently are 2 (no mirror-like reflection) and 3 (mirror-like reflection with Kr=Ks). More will be said about these material files in lecture.

Task

This assignment intentionally combines the previous two assignments and builds from them. It is recommended that as you complete this assignment, you simplify and improve your code where possible to make these and upcoming changes easier. It is also recommended that you implement the modifications in the following order:

  • Implement specular reflections. For details of how this should be done, reference the SageMath notebooks presented in lecture.
  • Implement shadows. This can be done by testing if each light source has a clear path to a point where a collision has ocurred. If not, that light does not contribute to the illumination of that surface point.
  • Implement models and .mtl file parsing.
  • Implement a recursive ray tracer. For details of how this should be done, reference the SageMath notebooks presented in lecture.

In this assignment you will construct three scenes: two scenes described in the two driver files given to you and one more scene of your choice by creating your own driver file with any objects and lights of your choice. Your code will be tested with two additional driver files, for a total of five files.

  • Scene 0 - the scene described in driver00.txt. Expected output is below.
  • driver00.png
  • Scene 1 - the scene described in driver01.txt. Expected output is below.
  • driver01.png
  • Scene 2 - the scene described in your driver (name it driver02.txt). This scene should have a recursion level of at least 3 and clearly demonstrate all features from this assignment. Please limit runtime to generate the .ppm using your program to less than 10 minutes (note that more time does not always mean a better scene).
  • Scenes 3 and 4 - used for grading, may include any features from this or the previous assignment.

In all cases the camera view, lighting, and object placement should result in a well rendered final image. The image should be written in PPM format as described in P2.

Submission

Submit a tar file via the CANVAS assignment page that includes:

  • Your source files
  • Your driver files
  • Your model and material files
  • Libraries if you use any
  • A makefile if appropriate
  • README.txt file that explicitly contains (1) A command to compile your program and (2) A command to execute it.

If you are using C++, your executable should be named 'raytracer'. If your are using java, the main executable class should be named 'Raytracer'. Notice the change in case for the first letter between C++ and Java. It is necessary for this assignment to take exactly two arguments as described above.


Reminder

There is no “late period”. Key is to start earlier and finish earlier. The program is due when it is due. All work you submit must be your own. You may not copy code from colleagues or the web or anywhere else. Cheating will not be tolerated, and will be handled in accordance with university and department policy.

Update Nov. 12, 2019 - grading drivers

To assist with preparing for p4, the drivers, models, and solutions used for grading are available at solutions.tar