Photon Mapping

Photon Mapping

Paper #

@article{jensen1995photon,
  title={Photon maps in bidirectional Monte Carlo ray tracing of complex objects},
  author={Jensen, Henrik Wann and Christensen, Niels J{\o}rgen},
  journal={Computers \& Graphics},
  volume={19},
  number={2},
  pages={215--224},
  year={1995},
  publisher={Elsevier}
}

Idea #

  1. Shoot photons from all light sources into the scene and store their contribution in a photon map (or light map)
  2. Render the scene normally (e.g. with ray tracing) and use illumination data from the photon map as a radiance estimate, see Light Physics

When a photon hits a surface #

Never store photon in the map on perfect mirrors: #

The only way it could contribute to the image, is if it comes from the perfect angle for the camera to pick it up later when actually rendering the scene, and that is super unlikely.

Otherwise store photon and choose one of the 3 #

(similar as Path Tracing )

  1. Terminate photon (Absorbtion)
  2. Diffuse reflection
  3. Specular reflection

Have material properties: photon_mapping_f6528886fb112f032054029c505565ef8dd3c820.svg for probability of diffuse reflection and photon_mapping_ff1777e92c87dc59443b5ebc1e9ecd20652a15fb.svg for probability of specular reflection.

photon_mapping_6cc71c32470932d5be7a5dba2fe393ea7c8201e1.svg (Energy conservation)

Generate random number photon_mapping_0ffd7d8c7e8049e1467690d427bf21e1a1f9e2a7.svg between 0 and 1:

  • If photon_mapping_bbd6d229cd24504a71c89670913cd6c5825dc678.svg then reflect diffusely
  • if photon_mapping_225fb2bbe6947d321fdcc6de69da8c4aa86bdc44.svg then reflect specularily
  • else terminate (absorbtion)

Probability of a reflection vs absorbtion #

photon_mapping_b0738f4d5399b654c4b0ad804aab2142a963b654.svg

Probability of a diffuse vs specular reflection #

photon_mapping_8f02acac48bde64589625125624fe56a2c6fcf32.svg

Two-photon-maps approach #

  1. Caustics Map:

    • terminate on diffuse surface
    • at least one specular bounce
    • high number of photons
    • [if known] shoot more photons at objects that should generate caustics
  2. Global Photon Map:

    • No preferences or ristrictions
    • More coarse distribution

Implementation #

Photon struct #

The photon struct as it is stored in the light map

   struct Photon {
       f32 x, y, z;    // position
       f32 phi, theta; // incident dir
       f32 r, g, b;    // power per band
   };

Energy of the emitted photon #

Distribute light energy equally

photon_mapping_1a2f6ace0dd8cd426d529de35b57a2fda07d280f.svg

Using the photon map for backwards rendering #

Sample the Photons around the area of interest.

  • Spherical is easiest but also will pick up wrong values
  • Ellipsoid is better but can still be wrong

When collecting around a radius near a edge of the geometry, it can happen, that you get a lower sample density and it will look like less light hit there per area.

Preventing shooting rays out of the scene #

  1. Render the scene from the lights perspective into a cube map (storing only 1 or 0 for each rendered object)
  2. Only shoot into the directions where objects where hit in (1)

Further improve the radiance estimate #

  • Use distance weighting, so photons further away have less influence.
Calendar October 22, 2023