Motivation

In the past assignment you wrote code for a ray casting system capable of rendering polygonal scenes described in the driver files. In this assignment you will be adding more capabilities. In particular, you will add an ability to render spheres, specular reflection, and shadows. You should expect to have zero or more light sources and zero or more objects in the scene. Objects could be .obj models or spheres. You are not being asked to perform reflections i.e., recursive ray tracing. Recursion will come in programming assignment 4.

Data Formats

The driver file used here is identical in format to that used in the previous assignment with one exception. There is a new field specifying additional sphereical objects.

sphere -1.0 -1.0 -1.0 5 0.2 0.2 0.2 0.5 0.5 0.5 0.5 0.5 0.5 1.0 1.0 1.0

 

There could be zero or more spheres. The first three values are the x, y, and z coordinates of the center of the sphere in world coordinates. The fourth value is the radius of the sphere. All the next values are the simplified material properties indicating the 'color' of the sphere in terms of red, green, and blue. First triplet after the radius represents (Ka_red, Ka_green, Ka_blue) ambient coefficients. Next triplet represents diffuse (Kd_red, Kd_green, Kd_blue) coefficients. Next we have (Ks_red, Ks_green, Ks_blue) specular coefficients. Finally, we have (Kr_red, Kr_green, Kr_blue) attenuation coefficients. Your are not going to use the attenuation coefficients for this assignment. For spheres use phong constant = 16.

Task

By intention, this programming assignment is meant to be a modest extension of what you already built in Assignment 2. Your approach should be to use it as a opportunity to simplify and improve where possible your current code and then in sequence add each of the three new functionalities. Each now functionality, in and of itself, is modest in scope. For grading you will be asked to render two scenes as defined by driver files and models being provided to you. In addition, you must design and render your own scenes. A big part of what will make makes your new scenes interesting will be in the interaction of objects through occlusions and shadows.

To accomplish this assignment you must complete three principle tasks:

  1. Implement a specular reflections. For details of how this should be done, please use the Sage Notebook illustrations presented in lecture.
  2. Render spheres by implementing ray-sphere intersection as discussed in the class. Again, please use the Sagemath notebook illustrations for this.
  3. Write code that renders scenes with shadows. This is done by testing for each point light source whether it has a clear view of the surface point being illuminated. If not, then that light source does not contribute to the illumination of the surface point.

You are encouraged to structure your work so you complete each of these in sequence before moving onto the next.

In this assignment your code will be responsible for correctly rendering five scenes, three of which are described in the driver files given to you in the drivers_models.zip file provided below and the other two will be of your choice while adhering to the guidelines described below.

Scene 0:
The scene described in driver00.txt
Scene 1:
The scene described in driver01.txt
Scene 2:
The scene described in driver02.txt
Scene 3 (name it driver03.txt):
Construct a scene involving at least four spheres. Light this scene using at least two point light sources. Demonstrate that your code properly handles partial occlusion between the spheres in the scene.
Scene 4 (name it driver04.txt):
Construct a scene using two polygonal models (.obj) consisting of at least 100 triangles. Light the scene with at least two point light sources.
As before, your rendered image should be written to disk as an image file in PPM format (see Assignment 2 for details on PPM format). In coming few days, we will update below the example ppm outputs for the first two driver files. Note that your ppms may not exactly match with these and they may vary slightly depending on a variety of factors. Grading is based upon our viewing your output rather than direct numerical comparison.

Your program will take two command line arguments. The first argument is a driver file. The second argument is the name of the image your program will write back to the disk in the same folder where your executable is located. A C++ example is:

$./raytracer driver00.txt driver00.ppm

Submission

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

  • Driver files (driver03.txt and driver04.txt) and model files necessary to demonstrate scene 4.
  • PPM files generated for driver03.txt and driver04.txt
  • Your source 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 must for this assignment to take exactly two arguments as described above.

Reminder

There is no “late period”. It is essential 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.

Addendum (Last update: 10/22/2018 Guru)

Fixed a statement that said 'four scenes' instead of 'five scenes'.

scene_ppms.zip file is available now.

Addendum (Last update: 11/07/2018 Guru)

Here are the unkown test cases test_cases.zip