Shadowblots

I think it looks like an angry pig

The image above uses the following techniques: Originally I wanted something artsy--maybe a chandelier in front of a decorated wall. Seeing that I could neither find a chandelier nor generate one without serious time investment, I started working on some simple perl-able objects I could quickly generate on my own, finally coming up with the scene above.

Photon Mapping

I began by incorporating Professor Jensen's Photon Mapping implementation, Thanks to bug-free code, in short order I could create dazzling, inaccurate images. The first test renders were pretty interesting, such as this shadow caster I made with perl. The left image is ordinary raytracing, the right with photon mapping. Both have the light source inside, although the photon mapping isn't quite ironed out in the second image. It looks really cool though. Sort of cosmic.

The previous scene was interesting, but very unrealistic. As I fiddled with the settings, I started getting better images. I started some early renderings of the Cornell box(model courtesy of Sunny Chow and Diem Vu) The color bleeding is apparent, althoug there are some interesting artifacts. Photons seem to bleed through the top of the box, for instance.
From last quarter's Math 155B, I knew anti-aliasing was going to make a huge difference in the quality of images, so early on in development I made sure to throw that in. It's just a simple box-filter, but it really cleans up the edges.
Finally, I threw the spheres into the cornell box, for an early, unrefined caustic.


Constructive Solid Geometry

Playing with lenses would be great. So I implemented boolean objects--union, subtraction, intersection. The image to the right shows light being focused onto a wall through the intersection of two spheres. Because spheres aren't tesselated into triangles, they can act as perfect lenses.

That looked pretty neat. In fact, it kind of looked like a flashlight. Putting aside the lenses for a moment, I perled up a parabola. As every engineer knows, a light source at the focus of a parabola should shoot a beam of parallel light. Of course it's not quite like that in the real world, since there's always the bulb in the way. But in a raytracer, that rule doesn't apply. The image on the left is a light source inside a parabola, shining at a distant wall. The image on the right is a close-up of the spot. This was made with a point source and a parabola, and the point source still fired in random directions.


Chromatic Photons and Caustics

Part of the original concept(chandelier) was to have various rainbow diffractions from the glass. I decided I would be happy if I could get a prism to diffract. So I added the three lines necessary to fire three photons(a red, green, and blue one) in place of the monochromatic white. Add in a little transparency modification, and they had different indices of refraction. Then I threw a prism in front of the flashlight. An early result of this is shown in the picture to the right.

It turns out that prisms are finicky creatures, and they only create a spectrum if light strikes it at just the right spot, coming in at just the right angle(at the top, sligtly away from the normal. I made many, many trial-and-error renders, trying to come up with the magic angle. On the left is an odd version of success. Notice the banding--the three colors formed, to my surprise, three patches, a red one, green one, and blue one.

I did some more playing with it, and started firing photons which varied by hue instead of a simple red/green/blue. A simple random number for RGB would create a lot of gray photons, so a fully saturated color would work best. I rotated the prism around slowly, and managed to get a line spectrum up at the top of the distant plane. I have no idea why, but it looked liked a full spectrum, and I was satisfied that the chromatic refracting was working.


Setting the Scene

So it was time to start thinking of a scene to put this in. I started by building the parabola into an actual flashlight. I used a Mag-Lite for inspiration. And of course, I needed to test its focus.

Finding the focus of a flashlight in a raytracer is actually rather difficult. I know there's a simple, mathematical way to solve for where the light should be, but I ended up taking the experimental approach.




Still more attempts to focus. I decided on a light box, with mirrors, but for some reason, the mirrors wouldn't reflect light more than two or three bounces--the light wasn't parallel enough. Above are two attempts to focus it as tight as possible, mostly by playing with the light position. I realized, at a later date, that one of the reasons for poor focus was that my parabaloid model didn't use enough vertices towards its origin. I ended up just telling the light that the first mirror was caustic, which pretty much told it to fire photons at the mirror.

Here, the renders on the top go from .45 to .65 distance of the light away from the parabaloid's origin. Note the slowly increasing focus. Another set of renders is below. The top set used to be vertical, but was hastily Photoshopped so to horizontal. The bottom set is an actual screen grab of screen grabs.

I still didn't fully understand how and whether the prism was working. Aside from physics textbook descriptions of the light coming in, I couldn't tell if it was refracting the right direction, so I built a little test scene. The red and blue dots represent incoming light at differing angles and positions. The prism is a 45-45-90 degree triangle, scaled to the dimensions 1, 1.3, .7(This makes the peak noticeably sharper.)

Here's the same test scene, but the prism is scaled at 1, 1.3, .9 (slightly more equilateral than before) Now the dots have a huge refraction difference. The red ones are bent in an entirely different from the blue ones.

Satisfied that it does in fact refract, I just started putting it in front of the flashlight, rotating it, and seeing what happened. Here's an image of it [somehow] making a spectrum. The link is to a closeup of the spectrum, which looks curiously like a band of red, green, and blue. The visual effect of red and blue tints on white light is appealing, however.


Final Choices

But what kind of scene to make? At first I toyed with making a large number of mirrors, having the light bounce off of three or four mirrors before diffracting out of the prism. That didn't seem to work so well--The scene was spread out, the light tended not to survive more than three bounces, and it tended to emphasize empty space more than the cool diffraction.

I started making use of the lens I had earlier, and just started playing with it. I was looking for a good spectral pattern, when I noticed it made interesting shadows in the wall. The variation in the configuration was tiny--move the lens a little, rotate the lens a little... but the shape was very different. I settled on the one that I think looks like an angry pig for my final picture. Here were some other interesting arrangements.(The one on the top-left is my second favorite--it's like a ghost with either a big mouth or a semi-wicked smile. =) )

The final image seems to have lost something with JPG compression, so here's a link to a pdf screencap, with gradients in all its glory. =)


email:jwng_at_cs.ucsd.edu