Photon Mapping

Visually Finding Photon Properties

The alternative way to determine optimal Photon Mapping properties is to directly visualize the Photon Map. To demonstrate that, we will use the Original Cornell Box project.

First reset all Photon Mapping properties to their default values. Number of photons : 10,000, Sample Area : 100, Photon Samples : 100, Max Bounces : 15.

Then, this is the most important step, set Final Gathering to OFF.

In the render to file pannel, set multipass to ON but set the number of passes to 1. This is an important step When you visualize the photon map directly, you want only one pass in order to clearly see how the photons cover the surfaces. If you used more than one pass, because the light is sampled at different positions at each pass, it would be difficult to visually figure the actual area covered by each photon.

A render should produce something like this:

This is the polka dot syndrome. When the sample area is too small, you can clearly see the polka dots. The isolated polka dot size is exaclty the size of the sampling area and eack polka dot is actually one photon.

The photons overlap but they are still individually visible. Ultimately, you could truely see each individual photons if you rendered large enough and with a sample area small enough. Try setting the sample area to 20 and render for an example.

The idea of the visual procedure is to increase the Sample Area untill the direct visualization of the Photon Map gives almost acceptable renders.

By acceptable, I mean that the photons, in the scene, overlap one another and blur themselves to a point where they are no more individually noticeable and their illumination is nice and soft.

For instance increasing the Sample Area to 250 gives the render to the right which is still not quite acceptable.

The polka dots are still clearly visible on the short block front face but this particular face is not relevent in this scene since it faces the void and will always receive very little photons whatever the settings we may try. A look anywhere else, and in particular at the walls and the other blocks surfaces shows very eneven variation of irradiance.

Ideally, we want to set the sample area in such a way that the resulting photon merge will be much more smoother than what we have here and should look almost like an acceptable radiosity render. That is the irradiance on the walls and on the objects have a nice smooth gradient. Some noticeable blotches are acceptable (and unavoidable) but there should be no noticeable hard edges in the irradiance, except, in this case, on the small block front face.

Usually, a radiosity scene should be set inside a closed environment. The Cornell Box scene is an exception because, in this case, we want to replicate the illumination of a real box which had an opening instad of the front wall. Any opening in the scene that ends up into a void will unnecessarily generate photons that will hit nothing. Any photon that hits nothing will be replaced by a new photon so this increases the render time in a very inefficient way.

Increasing the Sample Area to 750 as computed by the Excel utility gives the render to the right, which could almost be usable as is.

When you reach a point where increasing the Sample Area does not improve the smoothness of the photon map anymore, then you have reached the limit of what the Photon Samples can give you. If you want to improve a little bit further, you will have to increase the Photon Samples property and then the Sample Area.

If you did the examples in this page, you noticed that direct visualization of the Photon map is much faster than with Final Gathering. Because of that, it is tempting to try to find direct visualization properties that would produce perfect illumination. However, it will not be possible to get a perfect illumination in that way. The direrect photon map visualization will always produce dark corners and edges on the illuminated objects. This is intrinsicaly related to the way irradiance is computed. So be already advised. The direct visualization of the photon map is suitable for finding appropriate properties by trial and error but it cannot be used as a replacement for Final Gathering.

Adjusting Photon Samples

For instance, increasing the Photon Samples to 500 and then the Sample Area to 1700, you would get the render to the right which, I personally think is pushing it a little too far as most of the irradiance gradients are completely lost. The previous setting left no large holes and kept the gradients very visible. There is a good compromise to be found somewhere.

In general, increasing the photon samples will produce less saturated illuminations. But the effect is really scene dependent. Changing Photon Samples in a highly detailed scence with lots of small objects or objects with lots of small modeled details may make a difference. But there is no formal way of determining its optimal value, unlike sample area.

If changing Photon Samples in a particular scene does not make any difference, then your scene does not have the complexity where it is necessary to increase the photon samples. In this case, it is always recommended to leave it to the smallest value as possible since it can have a big impact on render time.

I still haven't found a user-friendly explanation for this property but here is one: After shooting photons in a scene, we have a very noisy distribution of photons everywhere coming from everywhere. In order to make sense out of that, we need to compute a statistical irradiance values by averaging a certain number of neighboring photons around each individual photons in the scene. That is what "precomputing irradiance" does. The maximum number of neighbor photons that may considered for this statistical evaluation is determined by the Photon Samples property.

Visual procedure

  • Turn Final Gathering OFF
  • Select multipass but set only one pass.
  • Change the sample area incrementally to get the best photon distribution based at how dense the photons look on the surfaces.
  • If the density looks too washed out or flat, then lower the Sample Area
  • If the density looks too separated or dotty and muddled or full of variation, then raise the Sample Area.

Conclusion

The interesting aspect with this method of searching for the optimal properties is that you have a visual way to judge the irradiance distribution. It is a good practice to use both methods. That is finding good estimates with the Excel utility and improving the estimate with the visual method.