CSS552: Programming Assignment #2

Fun with Phong Illumination Model

Due Time: Refer to the course web-site.


Objective

The goals of this programming assignment are for us to implement, experience, and understand the effects of each of the Ambient, Diffuse, and Specular components of the Phong Illumination model with Point, Directional, and Spot light types. Here are more details.

Approach

Please refer to my solution. Here are the command files. You should download and unzip both of these files, then double click on RTViewer.exe to run the sample program. Notice that in this version of the ray tracer:

  1. There are GUI support for switching on/off for each of the Ambient, Diffuse, and Specular terms in the Phong illumination model.
  2. Try switching each of the terms on/off and render to see the effects (and combination of effects) of those terms.
  3. In the NdotL and (VdotR)^n computation, the corresponding values are computed and assigned to Color.R,G, and B to show the float result as a gray scale color. Notice that the over saturation (very white result) is caused by addition of all the light sources in the scene. There are three lights, so, for example, for each visible point I compute and add NdotL for each of the light sources, resulting in a floating number greater than 1.0 for many of the locations.

In this assignment, you are to compute each of the Ambient, Diffuse, and Specular components, and depending on user settings, display your computed results properly. Please download this starter project (my mp1 solution, with slightly more light support plus the GUI interface) and unzip the source code.


The RayTracer Project

By now, we should all be quite familiar with this project from our mp1 experience. In mp1 you spent time implementing the visibility computation in the RTCore_Compute.cs file. In mp2, we will implement the Phong illumination model in the ComputeShading() function in the RTCore_Shade.cs file. The ComputeShading() function is invoked once to compute for the color of each visible sample from the ComputeImage() function.

If you open the RTCore_Shade.cs file, you will notice the, mShadeAmbient, mShowNdotL, mShadeDiffuse, mShowVdotR, and mShadeSpecular instance variables, your ComputeShading() function should compute a color by obeying these variables:

The RTSupport/SceneResourceSupport/Light folder. New to mp2 is the more careful parsing of the light source types. A RTLight object has an instance of RTTypeLight. RTLightType can be one of: RTLightType_Point, RTLightType_Directional, or RTLightType_Spot. The provided code parses the command file and create the corresponding light object with the proper parameters. RTLight has four functions, where each the implementation simply turns around and calls the corresponding funciton of RTLightType:

  1. InitializeLight(): Allows you to initialize the RTLightType if you so desired.
  2. GetColor(Vector3 visiblePt): Returns the color of the light as seen by visiblePt. For example, if a visible point is outside of the spotlight's illumination code, this color should be black.
  3. GetNormalizeDirection(Vector3 visiblePt): You MUST override this function in the RTLightType class hierarchy!! Proper L-vector must be computed and returned.
  4. GetLightPosition(): returns the position of the light source.

In this programming assignment, all your code should only go into the RTLightType class hiearachy, and ComputeShading() function with minor modification (if any) to the ComputeImage function.


Credit Distribution

Here is how the credits are distributed in this assignment:

  1. 5%: Ambient: show proper color
  2. 30%: NdotL
  3. 15%: Diffuse Shading
  4. 25%: (VdotR)^n:
  5. 15%: Specular Shading
  6. 10%: Proper submission and proper math operations

Extra Credits

This programming assignment will count 10% towards your final grade for this class.

Hints: