Skip to content

Repository files navigation

Photon Mapping

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

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.

FullGlobal_3xSS_FullSize_ImportanceX100_UnitSquare50_NoGammaCorrection_10kPhotons_500NNS

Direct Illumination Only

This image renders the scene with only direct illumination, meaning without using the photon map. As a result, the ceiling is not illuminated.

Area Light Direct Only

Caustics Only

This image shows only the caustics component of the full render.

Area Light Caustics Only

Indirect Illumination Only (Direct Visualisation)

This shows only the indirect illumination of the full render, but uses direct visulisation of the global photon map to generate the indirect illumination.

Area Light Indirect Only Direct Visualisation

Indirect Illumination Only (Importance Sampling)

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.

Area Light Indirect Only Importance Sampling

Full Global Illumination With Direct Visualisation Of The Photon Map

This image renders the scene using the photon map, and uses direct visulisation of the global photon map for indirect illumination.

Area Light Global Illumination Direct Visualisation

Full Global Illumination With Importance Sampling Using The Photon Map

This image also renders the scene using the photon map, but uses the photon map to generate optimised sampling directions for indirect illumination.

Area Light Global Illumination Importance Sampling

About

A Java implementation of photon mapping from scratch, exploring global illumination, caustics, and importance sampling.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages