Ray Tracing: Photon Mapping
Ray Tracing: Photon Mapping
Assignment Summary
Add photon mapping to the distributed ray tracer from here; support indirect illumination and caustics.
The Code: (Download)
New features:
‣Photon Mapping with support for point and spherical lights.
-Indirect illumination
-Caustic illumination
‣Smooth dielectrics.
New 3rd-party software packages:
‣ANN: A Library for Approximate Nearest Neighbor Searching. A kd-tree package from the University of Maryland.
Note that Apple’s Xcode 3.1 was used as the development environment.
Photon Mapping
I implemented a subset of features described in Jensen’s photon mapping work. Jensen’s approach breaks the rendering equation into separate rendering passes including a indirect illumination pass, caustic illumination pass, and distributed ray tracing pass (direct illumination). Images from the indirect and caustic passes are simply added to the distributed ray tracing image. Jensen also uses photon map information to accelerate the distributed ray tracing pass. However, I did not attempt to do this in this assignment.
Features I implemented from Jensen’s work:
‣Indirect illumination using a general photon map. My approach was straight forward: A point light or spherical light emits a number of photons at random directions. If the photon strikes a diffuse surface, the photon is absorbed or reflected. In my code, there is a 50/50 chance for either action. On reflection, the photon color is multiplied by the color of the diffuse surface and power attenuated (this implements the underlying feature of indirect illumination). Russian roulette is used to cut off deep recursions. If the photon strikes a non-diffuse surface, it is always reflected (see limitations).
‣Caustic illumination using a caustic photon map. My caustic map is similar to my general map except that a photon is recast if it does not immediately strike a specular surface. Caustic photons bounce around the environment until they strike a diffuse surface. This insures that all photons in the caustic map relate directly to a caustic illumination.
Limitations:
‣I was unable to implement BRDF materials in this assignment. I had originally planned to do so, but my existing ray tracer material architecture made it difficult to accomplish. I opted to focus on the indirect and caustic basics before pursuing BRDFs. I ran out of time to revisit BRDFs. As a consequence, only three material types are supported: Lambertian surfaces, perfect mirrors, and smooth dielectrics (with attenuation). Lambertian materials reflect a photon at a random direction within the hemisphere defined by the surface normal at point of impact. Perfect mirrors reflect photons at the perfect reflection angle. Smooth dielectrics randomly reflect or “absorb” photons. Reflected photons are reflected perfectly. Absorbed photons are recast within the dielectric object and traced to their exit point (with power/color attenuated) and the photon continues on its way through the scene.
‣The photon mapping technique is rather disjoint and it is difficult to balance the strength of each rendering pass. I found that there is a fine balancing act between photon map passes and the traditional ray trace pass. That is to say, the final image can easily be overpowered by a particular pass. Several parameters control the intensity of a photon-pass’s image: (1) number of photons cast. (2) power of each photon. (3) search radius for photons in rendering. (4) or alternatively (to 3), number of neighboring photons to fetch in rendering. It is difficult to balance these parameters. I found the task to be very scene specific.