CISC440 S2016 HW4
CISC 440/640 -- Computer Graphics
Due: Saturday, May 14 (adjusted because I posted code late)
YOU MAY WORK ALONE OR WITH ONE PARTNER
In this assignment you will write a basic ray tracer. A substantial amount of starter code is provided in a template program called udray (make sure you have version 6) which takes care of many of the low-level details of parsing, data structures, transformations, etc., as well as containing high-level functions outlining the ray tracer. udray v6 is intended to be dropped into the OpenGL tutorials code tree in the same manner as the previous projects; here is the accompanying Linux CMakeLists.txt.
Your job is to fill in missing code in key functions to complete the implementation. Every place in main.cpp that requires additional code or some modification is marked with the comment FILL IN CODE. You may make support functions and types as necessary, but try to make all changes in main.cpp rather than udray.cpp, udray.hh, or the shaders. In your README any changes made elsewhere must be noted, as well as who did what if you are working in a pair. DO NOT SUBMIT .obj files to Sakai, unless you use one not included in udray.
- Complete DIFFUSE section of shade_ray_diffuse() [2 pts]
- Complete shade_ray_local(), which adds specular and shadow effects. This may call shade_ray_diffuse() [3 pts]
- Complete reflection component of shade_ray_recursive() [3 pts]
- Add sphere intersection testing in intersect_ray_sphere(). This function should parametrize the Intersection object returned (with material information, normal direction, etc.) like intersect_ray_glm_object() does [3 pts]
- Scene complexity and creativity [4 pts]
As the last point implies, you must not only implement the ray tracer but also create a scene that shows off its functionality. Do this by creating a custom .scene file (see below for format) to arrange objects, place lights, and choose a camera angle. Feel free to create your own objects as .obj files using a 3-D modeling program -- this would be one way to make planes to show reflections and shadows very clearly.
On Linux, the code expects the .scene file to be specified on the command line as follows: ../build/udray teapot.scene (a provided example). On Mac or Windows, you may change the code to avoid the use of the command line as you see fit, but only comment it out so we can put it back for grading.
Submit the image that you produce as a .ppm or your favorite image format, along with the scene description file that produced it. The scene you create should demonstrate as much functionality as you implement, including diffuse shading, shadows, and reflections (to a depth of at least 2 reflections) on multiple objects and spheres. All submitted images should be rendered at a resolution of at least 500 x 500, although a much smaller image size is recommended while you are debugging.
Grad students only
- Add support for refraction in shade_ray_recursive(). You may assume that there is no nesting of transparent objects (this means that spheres should be regarded as solid) and that the medium outside the objects is air [2 pts]
- Add some version of glossy reflection, soft shadows, ambient occlusion, adaptive supersampling, or another advanced distributed-ray technique. Your submission should include images rendered with and without this option for comparison [2 pts]
- Implement bounding spheres around objects to speed intersection calculations. Report timing comparisons with and without bounding volumes for your scene. [1 pt]
.scene file format
There are several kinds of commands contained in a .scene file type, each appearing on a separate line. Lines 1-3 are mandatory. Whole lines can be commented out by starting them with '#'. Here are the command types:
1. Camera position: camera x y z dx dy dz upx upy upz. Always the first command in the file; arguments work like gluLookAt().
2. Clip planes: clip left right bottom top zNear zFar. Always the second command; arguments work like glFrustum().
3. Image dimensions: image width height. Third line in file. By reducing the image size, you can debug your code without waiting too long for it to run.
4. Background: background solid r g b or background cubemap path_to_cube_map.ppm. Rays that don't hit anything either get a solid color or read a pixel from a cube map surrounding the scene. Several example "vertical cross" cube map images in .ppm format (taken/adapted from , , and ) are in the data directory. The background will be solid black if not otherwise specified with this command.
5. Light(s): light x y z amb_r amb_g amb_b diff_r diff_g diff_b spec_r spec_g spec_b. One light per line.
6. .obj object(s): obj path_to_file x y z sx sy sz rx ry rz amb_r amb_g amb_b diff_r diff_g diff_b spec_r spec_g spec_b shine IOR reflectivity transparency. One object per line. (x, y, z) positions the object, (sx, sy, sz) scales it along each axis, and (rx, ry, rz) specified pitch, yaw, and roll rotation angles in degrees. Subsequent values parametrize material properties (overriding any that may be in the .obj file itself).
6. Sphere(s): sphere x y z radius amb_r amb_g amb_b diff_r diff_g diff_b spec_r spec_g spec_b shine IOR reflectivity transparency. One per line.