CS6620 | Advanced Graphics 2 | University of Utah |
Prof: Peter Shirley | Ray Tracing | Sem: Spring 2002 |
|
Assignment 02 - Basic Ray Tracer 2 |
On top of the framework I built for Assignment 01 - Basic Ray Tracer 1, I've added lighting, shadows, triangles and viewing. The lighting uses a fixed ambient term and adds that to the contribution of each light in the scene. Each lights contribution is computed by modulating the diffuse material color by the light color, then multiplying that result by the normal at a point on the surface dotted with the light direction: diffuse = Kd * Id * ( n.Dot( l ) );Lights are specified in the scene file as follows: light X Y Z Radius R G B(the radius is currently ignored.) Shadows are computed by sending a ray toward each light in the scene from a point on a surface and determining whether something in the scene is blocking the light. Triangle intersection is computed using barycentric coordinates and Cramer's Rule. Because triangle intersection is expensive, I cull any triangles whose normal faces away from the gaze direction. Triangles are specified in the scene file as follows: triangle Ax Ay Az Bx By Bz Cx Cy Cz R G BWhere A is the first vertex, B the second and C the third. Triangles are assumed to be wound counter-clockwise. Support for triangle meshes is forthcoming. Viewing is specified by providing the eye position, a position to gaze at and an up vector. The field of view is currently fixed at 45 degrees, but I hope to implement support for varying fov's soon. The view is specified in the scene file as follows: view Ex Ey Ez Gx Gy Gz Ux Uy UzWhere E is the eye position, G the position to be gazed at and U the up vector. Note that the view specification must come before any triangle specifications for the triangle culling to work properly.
(unless otherwise noted). |
1: 10 spheres, 2 lights: 0.24 seconds. 2: 91 spheres, 2 lights: 1.59 seconds. 3: 820 spheres, 2 lights: 15.65 seconds. 4: 7381 spheres, 2 lights: 286.78 seconds. (click on each of the images for a larger view). |
||||||||||||||||
1: 1692 tris (847 culled), 2 lights: 14.12 seconds. 2: 1692 tris (859 culled), 2 lights: 19.67 seconds. 3: 1692 tris (750 culled), 2 lights: 20.44 seconds. 4: 1692 tris (801 culled), 2 lights: 17.53 seconds. (click on each of the images for a larger view). |
||||||||||||||||
I created an animation from these frames (in quality order): Poor: Indeo Video (155 Kb) Good: Intel IYUV (2.307 Mb) Better: DivX MPEG (182 Kb) Best: Uncompressed (4.611 Mb) (click on each of the images for a larger view). I thought that there was a weird lighting bug in my code when I saw the flecks of light on the corner spheres. But, I realized that these are bits of the spheres that are not in any shadow and the highlights are caused by the lights on the sides peeking through the sliver of air between the outside slabs of spheres. |
||||||||||||||||
|
||||||||||||||||
All of the images above can be regenerated by specifying the appropriate
scene file on the command line of the rayn program
rayn-02.zip (1.42 Mb). The source code is included
in the zip file. Here is a description of the command line parameters for
rayn.
rayn [@response] [options] options: -output <output_file> output image filename (string). -size <width,height> size of output image (int,int). -background <red,green,blue> background color (int,int,int). -scene <scene_file> file containing scene description (string). @reponse: Specifies a file from which options are to be read, one option per line. Options which are specified on the command line override those in the response file. |
Questions/comments to nate@pobox.com. |
|
January 2002 © Nate Robins |