CS 426 Computer Graphics Assignment 5 Ray Tracer Rob Jensen & Ian Buck NOTE: This assignment is late but we are both using our 2 day grace period. Application Title: NetherRay URL: http://www.princeton.edu/~ianbuck/NetherRay We have implemented all the required features for this assignment including the following: Triangles Circles Phong Shading Specular, Diffuse, Ambient Lighting Point and Parallel lighting Shadows Notes: The Specular highlights may look different than raycharles because we are not using the approximation but rather calculating the real reflection vector. Also we implemented a few extra tidbits including: Reflections (0.5) (trace depth is implemented) Procedural Shaders (1.0) Spotlights (0.5) Anti Aliasing (0.5) Depth of Field and Camera Aperture (1.0) Soft Shadows (1.0) -- Procedural Shaders -- Procedural shaders are implimented with roughly the same syntax as Pixar's RenderMan shading language. You can write a new "shader", a function that is given the position (P), normal (N), and lots of other parameters (UV coords, light info, etc), and returns the return color of the ray. You can pretty much cut and paste a RenderMan shader (many are available on the net) into the code. Many conveniece functions from RenderMan are implimented and available to the shader such as "noise", "mix", "smoothstep", plus "ambient", "diffuse", and "specular", which loop over the lights and return the combined luminance. Note: We borrowed code for the noise function. The file noise.C was copied out of "Photorealism and Ray Tracing in C" by Charles Watkins. Implimented procedural shaders include: plastic (default): Specular highlight is white metal: Specular color is the color of the material glossyPlastic: Reflective using Ks for reflective factor wood: A solid wood shader marble: A Marble shader - solid fractal noise checker: A checkerboard shader based on U and V parameters glass: Snell's law in action. This fires both reflective and refractive rays. To implement a shader in the .tsd file, type "shader wood" to turn on that shader for the objects defined folling this call. If no shader is specified, plastic is used. See the sample file shaders_alias.tsd and shaders_alias.ppm. ---- Anti Aliasing ---- Anti_aliasing (if turned on) shoots multiple rays through the pixels and averages the returned color for each of those rays to deturmine the pixel color. To run an image with Anti_aliasing, include the call "anti_aliasing n" in the .tsd file where n is the number of rays to shoot per pixel. Good results have been achieved with n=10 however this can dramatically reduce the speed of the rendering. If the anti_aliasing call is not included, a single ray is fired through each pixel. See shaders_alias.tsd and shaders_alias.ppm for examples of anti-aliasing. ---- Depth of Field and Camera Amperture ---- To obtain realistic camera features (i.e. focusing), turn on the camera aperture with the call "f_stop n" where n is the F-Stop of the camera. Similar to a real camera, setting f_stop to a high value causes a large depth of field where a small value is a short depth of field. The focal plane of the camera is specified by camera_target. Object which are focal plane will appear in focus while objects above or below, out of focus. To get realistic results, include the call "aperture_rays x" where x is the number of rays fired per pixel in computing the focus. Note: the smaller the f_stop, the higher aperture_rays should be to get a realistic picture. See blurred.tsd and blurred.ppm for examples of depth of field. ---- Soft Shadows ----- For smooth shadows, a new light source was defined called "soft_light" which has the same physics as a point light however it has also defined with it a radius, making it a spherical light. The arguments to soft_light are the following: soft_light r g b x y z size rays The rays argument is how many rays the render uses to generate the soft shadow. The more rays the softer and less pixelated the shadows will appear, however it will take longer. See Smooth_shadow.ppm and Smooth_shadow.tsd for an example. The only light in that image is a soft_light. ----- Debugging stuff ----- We are particularly proud of the debugging code built into the raytracer. If you don't compile with the "-DDBG_NONE" flag, you get a complete trace of the program to stderr. With "NetherRayFireOne", you can give pixel coordinates on the command line (from xv, for example), and see exactly what objects were hit and the returned colors, etc. An example traced ray is in "exampleTrace.txt" Note on compilation... I expect this program to be portable with minor difficulties to other systems (better than Rob's last few programs). There are no tricky Inventor libraries or anything. You can turn off MakeDepend in the makefile by getting rid of the compiler flag and the include statement at the bottom. It should work, however.