# Homework 11 - Photon Mapping

For this project I took a different approach to global illumination called Photon Mapping. The algorithm is pretty simple: emit photons into the scene, let them bounce and scatter until they absorb, and compute the brightness based on the number of photons absorbed. My primary resource on the technique was Realistic Image Synthesis Using Photon Mapping by Henrik Jensen.

Here is a summary of the algorithm I used.

1. Emittance
I picked a random point on the light source and chose a direction based on a cosine emittance function, and fired the photon in that direction.
2. Reflection
The photon hits a polygon. The next action the photon can take is either to absorb or to reflect. My algorithm uses a Russian Roulette technique to decide what to do. Instead of depositing a fraction of the photon's energy and reflecting the rest, the entire photon either absorbs or reflects. I made things simple and chose a 50% reflection rate. If the photon reflects, the algorithm recurses and the photon emits again according to the rules in step 1.
3. Absorbtion
There is a 50% chance that the photon will aborb upon collision with a triangle. In this case I just leave the photon where it is and draw a point in the Inventor application to visualize its location. I also increase the hit-triangle's brightness by a small constant value.
4. Illumination
Normally the lightness level of a region is calculated from the density of the photons in the vicinity. My algorithm just uses the number of photons that hit the triangles containing that vertex (See step 3).

The main difference between this method and the global illumination technique of the previous homework is that there we looped through all the vertices, gathering both direct and indirect light, while here we shoot light from the source into the scene and let it pile up.

I suspect the two algorithms do the same calculation but in different order. The previous one is target-order while this is source-order.

## The Photon Map      ## Illumination based on Photon Map    This is low-resolution. I need to redo it at a higher resolution.

## Source

hw11.tar.gz (22k)
- Compiles on IRIX and Linux
- -b option requires brain2 data set, available upon request (maybe)