Ben Elgin

Comp 238 Project 2

Submitted 06 Oct 1999 (on time)



A Second raytracer: antialiasing, soft shadows, glossy reflection, textures.

Here is the CODE for this project. Compilation works with "CC kiray2.cpp kirtrace.cpp ppm.cpp -lm" on an SGI. Other compilation environments untested. More info can be found in the README file.

Note that I made some improvements to my proj 1 code before starting proj 2 features: I fixed the speckled triangle bug, I made a better floor plane from tris, I upgraded shadow rays to account for transparent (partial) shadows, and I attempted to spped up some of the math.

Now some images from the developement. First, antialiasing. I used a variation on the jitter method: the center of the pixel is always sampled, and then four other rays, one from each of four pixel quadrants, are sampled. At first I assigned a weight of 1/3 to the center ray, and 1/6 to the others, later I tried weighting each ray 1/5. It didn't seem to make much difference. More rays would look better, but of course take longer to run. Below you can compare the original render to the antialiased one. (The difference is a little more obvious in the original ppms than in netscape jpegs.) (original time 9 sec, new time 42 sec. note I also reduced trace depth to 3)

pic1.jpg pic3.jpg

Next, glossy reflection. This also involved creating jitter rays, but in a slightly different manner. Given the usual reflection ray, I find two vectors both perpendicular to it, and scale them by a #def'ed glossiness factor. I then create a given number of jittered rays (I used 6 here) by adding random amounts of these perpendicular vectors to the original ray. (58 sec)

pic4.jpg

This next picture shows both antialiasing and glossiness together. The gloss looks nicer this way. (292 sec)

pic5.jpg

Next was soft shadows. First I had to re-do my light objects, making a base class, a point-light class, and a sphere light class. Every light now has a getSoftPos function, which returns a random location inside its volume. When tracing shadow rays, I simply trace to a certain number (6) of these jittered positions and average. (24 sec)

pic6.jpg

Next texture. Because I was running out of time, I perpetrated the following horrible hack: the texture is stored in the raytracer object (hence only one at a time). It is applied to any object with an Ia < 0. The coordinates are based on global XZ position alone (ie, it's as if the texture is being projected onto the surface from directly above). It looks decent, though. Here I used an old render as a texture. (24 sec)

pic8.jpg

Finally, everything together. Yay! Pretty! (antialiasing with 5 samples, glossy refl with 6 samples, soft shadows with 6 samples, texture. Total time: 767 sec, on Evans).

pic9.jpg