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.
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.
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.
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.
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. =)