I came up with a way to emit photons from an (infinitely far away) HDR environment map, weight them correctly, and distribute them properly over the entire scene. Below are a few shots of a scene I used to test my system. In this scene, a glass sphere is hovering slightly above a pedestal.
The first two shots below use the Grace Cathedral environment map. This environment map has tiny, bright lights that contribute greatly to the image yet are hardly ever hit when using naive backwards path tracing. I had already implemented HDR environment map importance sampling for direct illumination, but only after implementing photon mapping can I render caustics efficiently as well. My photon mapping system uses the existing importance sampling to select photon emission locations.
|Photon mapped indirect illumination, plus direct illumination (using environment map importance sampling).|
|No indirect illumination (except for ideal specular reflection and refraction of camera rays). Same shot as above except with photon mapping turned off.|
The next two shots use the Pisa environment map.
|Photon mapped indirect illumination, plus direct illumination.|
|Pure path tracing. Identical appearance to the image above (except for noise and imperceptible photon mapping bias).|