Implemented Photon Mapping from scratch in Java. My aim with this project was to push my problem solving skills by implementing a complex algorithm, so the code was quite experimental.
For a clean and polished project in ray tracing, look at my Ray Tracing in C++ repository. The C++ project implements path tracing instead of photon mapping but aims more towards clean and efficient code.
The scene is a simple Cornell Box containing two glass spheres and an area light. The larger glass sphere is relfective while the smaller glass sphere is refractive. Because the ceiling light is an area light, the ceiling will not be directly lit by the light (Only lit by reflected rays) and the shadows from the spheres should be soft instead of hard.
Below is a render of the scene using the photon maps (and importance sampling), along with representations of the two photon maps. The images of the photon maps are more for understanding than completely correct representation, meaning I have normalised the color values of photons so that we can actually see them. The photon map on the left (Middle image) is the global photon map, which stores all photons which are randomly reflected around the scene. The photon map on the right (Right image) is the caustics photon map, and this stores photons which were specifically targeted at the refractive sphere.
This image renders the scene with only direct illumination, meaning without using the photon map. As a result, the ceiling is not illuminated.
This image shows only the caustics component of the full render.
This shows only the indirect illumination of the full render, but uses direct visulisation of the global photon map to generate the indirect illumination.
Same as above section, but we use importance sampling instead. This means that we take the information from the global photon map, and use it to work out 'important' directions to sample the lighting from.
This image renders the scene using the photon map, and uses direct visulisation of the global photon map for indirect illumination.
This image also renders the scene using the photon map, but uses the photon map to generate optimised sampling directions for indirect illumination.