CPSC310A Assignment 9 - Reflectivity

Due Monday February 27


Modify your C++ ray tracing program to include the ability to render objects with reflective surfaces. The color of a reflective surface is computed by combining the color of the surface's material with the color computed from a recursive ray trace originating at the intersection location.

The amount of reflectivity of a surface is specified with the Ks term that is also used for the specular reflectivity of a material. Therefore, you do not have to modify your scene file parsing code. You should modify your illumination calculation function to compute a fourth term, reflective illumination with the equation:

Ir = Ks * R(θ) * illum(ray(p, r))

Where Ir is reflective illumination, Ks is the material's specular reflectivity, R(θ) is the approximation to the Fresnel reflectivity of a surface, p is the intersection location, r is the view reflection vector, and illum is the is the illumination of the closest object in the scene that intersects with the view reflection ray. The approximation to the Fresnel reflectivity is calculated with the equation:

R(θ) = Ks + (1 - Ks)(1 - cos θ)Ns

Where Ks is the material's specular reflectivity and θ is the angle between the view reflection vector and the surface normal at the point of intersection. If the scene contains more than one reflective object then the recursive illumination calculation can be infinite. Prevent this by terminating the recursion by returning the background color if the maximum recursive depth is reached. The maximum recursive depth should be specified with a constant variable.


Tar your code in a file that contains your name and submit it on the course Inquire site.