Photon Mapping
Final Project for MIT 6.4400 Computer Graphics
Previously in the course, we have studied and implemented a simple ray-tracing algorithm. Ray tracing, while effective for direct illumination, has its limitations when it comes to capturing intricate global illumination effects such as indirect lighting. Photon mapping provides a more realistic representation of how light interacts with surfaces in a scene. We chose to implement photon mapping upon our basic ray tracer on our self-created cornell box scene of hittables.
We followed the standard two-pass algorithm of photon mapping, first generating photons, and then rendering the scene using the generated photon map.
Photons are emitted and traced through the scene recursively, with their positions, directions, and weights updated based on their hit records with the scene. The direction is updated by taking into account the behavior of reflection and refraction. Following the paper, we implemented Russian Roulette to terminate photon paths probabilistically. For faster rendering, we used the kd-tree structure to store our photon map.
With the generated photon map, we moved on to the second-pass, which is rendering by shooting rays from the camera into the scene to simulate the interaction of light with surfaces. Each pixel in the image corresponds to a ray that is cast into the scene, and the resulting color is determined by the estimate reflected radiance using the precomputed photon map.
We sum the radiance of the k nearest photons with weights taking into account the material’s BRDF and the flux of the photon. We calculate the direct and indirect illumination using our global map, as well as the specular reflection using our caustic map. The meaningful difference is we applied cone filtering to assign a weight to each photon based on the distance between the point of intersection and the photon, this intensifies the caustic effects at the point of intersection.
The algorithm outputs the final color by adding the reflected radiance, direct illumination, and results from caustics. We achieved a combination of caustics, direct illumination, and indirect illumination, providing a realistic representation of light interactions within the scene.
We successfully implemented photon mapping for global illumination by building upon our existing ray tracer from assignment 4. The resulting rendering of the Cornell box shows a clear effect of reflection, demonstrating the successful integration of photon mapping for realistic reflection effects in our ray tracer. We also leveraged our implemented kd-tree data structure and OpenMP parallel programming to speed up the ray tracing by a considerable amount.