CS 6620 Advanced Computer Graphics II - Assignment 5

Zach Gildersleeve
February 23, 2007

Required Image

Here is the required image, as produced by the program. It took on average 66.2 seconds to render.

required5.ppm

Comparing my image to the required image, the dielectric shader (transparent shader) is not exact. My dielectric shader appears darker than the required implementation, but I could not track down the code that was contributing to this.

Code Listing

The code for this image can be found here.

Design Choices

This assignment implements a Phong shader, a pure reflective metal shader, and a dielectric transparent shader. All shaders are built on the Lambert shader. The Phong shader uses the half angle method of generating the specular component. The metal shader is built on the Phong shader. It uses the Schlick approximation of the Fresnel equation. Prior to computing the Phong specular component, the reflected direction is computed, and traced via an implemented overloaded traceRay() method in the Scene class, that shoots a single ray and returns the closest intersection similar to the render function. Ray tree pruning is implemented here, where the reflection ray is traced only if it falls within the maxDepth and minResolution parameters. The returned reflected color is multiplied by the Schlick approximation, and eventually added to the Phong component.

The dielectric shader is also built on the Phong and metal shaders. Values of eta and r0 are computed in the constructor, and used to determine the correct orientation of the ray, normal, and associated values - if the ray is going in or out through a more or less dense medium. Total internal reflection is checked for and computed if the cosTheta2sq is less than 0, otherwise the reflected ray and transparent ray is traced using the same traceRay function as described above. Finally, the Phong specular component is computed, and all the various color components are summed. Beer's attenuation is implemented in the dielectric shader; this is discussed in the Extra Credit section.

Creative Image

My creative image is made from 17 spheres, and 3 disc primitives. The spheres from center outwards are a Phong surface, dielectric transparency with green Beer's attenuation, dielectric transparent with blue Beer's attenuation, and dielectric surface with no attenuation. The spheres are on a reflective metal disc, which reflect them downwards. A second disc is angled towards the camera, and reflects the spheres as well. The third disc is behind the camera, and reflects everything for a more complex specular component for the spheres. This image took approximately 280 seconds to render, which is starting to take a long time.

Here is the same image, but with the starfield background. Since the traceRay method returns the background if the reflected ray does not hit anything, the stars are reflected in the spheres and on the disc.

Extra Credit

I implemented Beer's attenuation for the dielectric material. The DielectricMaterial constructor is overloaded, passing an optional Color parameter initializes the Beer's attenuation log function, while the actual attenuation is computed as a separate function in the dielectric class. The below image is the required image, with the DielectricMaterial using a Beer's attenuation color of (0.0, 1.0, 0.0).

Additional Comments

The required image took me about 15 hours, and was fairly straightforward given the methods presented in class. The creative image took about 3 hours to do, as I played around with different options before landing on the final image.