Warning: fopen(/home/follick.ca/rt/logs.txt): failed to open stream: Permission denied in /home/follick.ca/rt/common/top.inc.php on line 2

Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/follick.ca/rt/common/top.inc.php on line 3

Warning: fclose() expects parameter 1 to be resource, boolean given in /home/follick.ca/rt/common/top.inc.php on line 4
Ray Tracing with Caustics
Ray Tracing

Functionality
Parameters
The main parameters to work with are the number of photons to shoot per light, and the gathering radius of the photons. When it comes to radiosity, the maximum number of bounces allowed during the photon map creation becomes a bigger factor.

Number of Photons
During the photon map creation stage, each light is taken in turn and must launch a massive number of photons out into the scene at every direction. The result is that only a fraction of these photons will end up hitting diffuse surfaces and for caustics I only store photons if they've been reflected or refracted at least once. This means that depending on your scene, the vast majority of photons launched from light sources won't be stored for caustics. Some implementations help to speed up the process of shooting these photons into the scene by detecting directions with more scene geometry and thus a higher probability of the photon being stored. I did not implement this due to the added complexity and the minimal gain in speed with respect to the rest of the rendering.

Photon Radius
When lighting at a given hit point is to be determined, the ray tracer goes through the gathering stage. It traverses through all the photons in the map to determine which ones are within the radius of the hit point. The more photons there are within this radius, the brighter the hit point becomes. Each photon within the radius contributes a certain amount of light depending on its colour (from its light source) and its final intensity after travelling throughout the scene through various mediums.

Results
The following results were originally rendered at 800x600 at 1 sample per pixel on a P4. They all include an area light, a refractive sphere (index 1.42), and a textured/bump mapped plane.

The first set of three all have a photon radius of 0.55 whereas the second set of three have 0.05 for their radius.

The general trend is that the more photons there are, the longer it takes to render and the more memory it uses, but the better the result is. As well, the larger the photon radius, the longer it takes to render, but the smoother the result. Care must be taken to select a radius small enough so that the resulting caustics are sharp enough and not too blurry. If the radius is too small, the results will be grainy. It is very important to choose a small enough radius to keep things fast. It slows down considerably when the radius is large and the photons are grouped close together. This is due to the gathering from the KD-Tree algorithm - when the photons are close together, it must search many more adjacent photons since their radii overlap.
Click for Full View
< 1 second to create photon map
8 secs to render
100,000 photons shot
2,690 photons stored
0.55 photon radius
Click for Full View
2 secs to create photon map
10 secs to render
1,000,000 photons shot
25,527 photons stored
0.55 photon radius
Click for Full View
15 secs to create photon map
482 secs to render
10,000,000 photons shot
273,264 photons stored
0.55 photon radius
Click for Full View
2 secs to create photon map
8 secs to render
1,000,000 photons shot
27,303 photons stored
0.05 photon radius
Click for Full View
15 secs to create photon map
8 secs to render
10,000,000 photons shot
273,264 photons stored
0.05 photon radius
Click for Full View
92 secs to create photon map
16 secs to render
50,000,000 photons shot
1,276,368 photons stored
0.05 photon radius

Index of Refraction
The animation to the right demonstrates how the photons spread according to the index of refraction on the sphere.

Throughout the animation, the sphere's refractive index changes back and forth from 1.05 to 2.0, which warps the caustic. The other parameter to play with here is the distance between the sphere and the ground, which will focus the caustic in and out.