CS 6620 Advanced Computer Graphics II - Assignment 2
Zach Gildersleeve
February 2, 2007
Required Image
Here is the required image, as produced by the program. This image uses a PinholeCamera located at Point(-24, -2, -5.2).
The same scene rendered from Point(-24, -2, -5.2) illustrates the implemented single-sided lighting, where the bottom of the plane is visible only in the ambient light. It is a boring image, but a double-sided shading system was felt to be unnatural, as the bottom of the plane is indeed in shadow, and assumed to be opaque.
Code Listing
The code for this image can be found here.
Design Choices
The above code builds on the previous assignment. Separate header and implementation files are made for every component - Camera, Background, Light, etc., and each child class that implements one of these classes - PointLight, DirectionalLight, is its own separate file. Theoretically, this was done for portability, although it increased coding time, as well as build errors associated with forward declarations. The Vector and Point class was improved upon since the previous assignment to deal with this problem. In an attempt to manage the size of the program and rendering efficiency, references are passed almost exclusively, and const terms are used where ever possible to aid debugging.
Once the Lambert shading model was applied, it was obvious that doubles were required rather than floats, as the shading on the spheres had large artifacts, which went away using doubles, and an epsilon value of 1x10-6 where applicable. The Lambert shader itself flips the primitive's normal if (N dot L) > 0, and casts a shadow ray when (N dot Ln) > 0. The shading model seems to work in most test cases, but further improvement will be required later.
The Sphere intersection routine was vastly improved upon, and using the optimization tips presented in class, sped up considerably. The 'a' quadratic term is ignored, and the 4 and 2 are factored out. Other optimizations will be implemented
Creative Image
For my creative image I made a still life with various fruit, which was decided to be a standard artistic arrangement of various spheres. The grapes are a series of nested loops with several random multipliers to make things look fairly organic. The color components were selected using a third party application to pick color in the RGB colorspace; a future improvement to the raytracer will be a means of applying color on a 0-255 scale rather than 0-1.
Extra Credit
An orthographic camera was implemented from the Camera parent class. This camera OthographicCamera requires a Point position, and two Vector bounds u and v, which are the orthogonal height and width of the camera's viewing frame. All rays for the camera are thus perpendicular to this frame, and can be found via u cross v. The image below is the scene from the required image, with the camera at (0 0 0), with u = (0 -10 0) and v = (0 0 10). The plane is not visible as it is itself perpendicular to the camera's frame and parallel to all rays.
More testing is required to determine if this image is correct, but the orthographic camera will most likely not be used. Additionally, a gradient background and directional light were implemented, but will need to be troubleshot during subsequent assignments, if they are required.
Additional Comments
There were several long periods of troubleshooting with this project, most of which eventually was traced to a term in the Vector::normalize() function not being correct. Once that was identified, things progressed. It took approximately 50 hours for the entire assignment, which included troubleshooting and rewriting the Point and Vector classes. Without these problems, there was roughly 30 hours of steady work time. For these reasons, and the hour load within one week, the assignment was difficult to complete. The intersection math itself was not too difficult to code, and with the basic raytracing structure completed, hopefully future assignments will have a quicker development time.