Photon Mapping

Calculating the Sample Area

First Photon Mapping render

The result of rendering the Cornell Box scene with the previous settings should look like the picture displayed to the right.

Before continuing on to the radiosity properties settings, I'd like to multi-passes and render time.

Rendering this scene with Antialiasing (no multipass) or multipass with 1 pass or multipass with 9 passes, require basicaly the same render time and gives basically the same result. This is one important concept . On my computer, the render times were almost the same for all types of render:

10m35s for antialiasing render
06m33s for one pass render
10m55s for 9 passes render

You may have expected the 9 passes render to take approximately 9 times longer than the one pass render. But for Photon Mapping, this is not the case. For the Photon Mapping rendering engine, the most time and CPU consuming step is the Final Gathering step. And the time it takes is directly influenced by the number of Final Gathering samples. However, the Final Gathering samples are distributed among the passes. So when rendering only one pass, the final gathering need to sample all the 100 samples per pixel while when rendering 9 passes, each pass samples only 100/9 = 11 samples per pass.

So because of that, when you use Photon Mapping, you don't have to worry about using multipass. Multipass will not have a huge impact on Photon Mapping render times.

Getting the radiosity render right

The radiosity default settings are rarely appropriate for a given scene. A noisy render like that is indicative that there either is not enough photons in the scene or the Sample Area is too small. Since this scene is small compared to a normal room size, the noise is not so bad. But for a normal room size, the noise can look really bad.

As it turns out, for this scene, increasing the number of photons to 1 million would be an appropriate solution. But it would considerably increase the render time too. For such a simple scene, it is really not necessary to go to such high number of photons. We could actually decrease the number of photons and get a very acceptable radiosity render provided the Sample Area is adjusted appropriately. It is always advisable to try increasing the sample area first.

There are basicaly two ways to find the proper sample area. A visual procedure and a mathematical estimate. Finding the correct Sample Area is not trivial. It can be found by trial and error but there is a more systematic way to proceed which I will review later. But first, there is also a mathematical formula to help guess a good starting point. Instead of explaining this mathematical formula, I have concocted an Excel spreadsheet which you may download by clicking on the picture below.

For those without access to Excel, I've added a detailed mathematical explanation at the end of this tutorial page so you can do the math with a calculator.

So enter the room size which is 55x57x55cm and an estimate of additional object surfaces in the room. In the Cornell Box case, the estimate is simple since we know the tall and short blocs sizes which are 34x17x17cm and 17x17x17cm respectively. And since the room itself is missing the front wall, a 55x55cm area is subtracted which gives 443cm additional.

Simply enter the suggested Sample Area value in the property box and rerender at 9 passes. You should get a result similar to the render to the right.

That was easy.

Fortunately, for the Cornell Box scene, it is easy to estimate the total surface area. In most scenes, however, the estimated additional surface cannot be computed as easily and must be guessed. It is easier when the size of the room have been entrered and a relative additional surface area can then be guessed from that. For some other scenes, with a lot of nooks and cranies, the size of the room can only be used as a first estimate and finding the correct sample area will require further trial and error from that starting point.

As a rule of thumb, it is safer to have larger sample area than smaller ones. So it is better to guess larger additional surface areas than smaller areas. The larger the sample area from the optimal, the more the light bleeding approaches a simple ambiance setting. So ultimately, one could reduce the number of photons and increase the sample area to a point where each surface emits a constant ambiant component. For scene with several small surfaces, however, this may not be so easy to achieve.

Now that you have this Excel utility, you may want to try with lower and higher number of Photons. See how low you can go and still have acceptabe radiosity renders by setting the appropriate sample area. And see how the number of photons in a scene affects the render time.

Computing the Sample Area with a calculator

The idea is to estimate a sampling area that will most probably leave no holes in the photon coverage. The information we need for that are : the total surface area to cover with photons and the area that is covered by each photon irradiance estimate.

The most significant measures to help estimate the surface area to cover with photon is the size of the room. Here, the room was 55x57x55 cm. So the total surface area of the room is the sum of each wall areas. There are 4 walls of 55x57 and one wall of 55x55 (the front wall is missing) so we have (55x57x4) + (55x55) = 15565cm². Then we need to add the estimated area of all the objects in the room. In most situation, it is not practical to actually compute the surface area of each objects the way we did it for the Cornell Box. A rough guess will do just fine and an overestimated guess is better than an underestimated guess. So let's say we guess 5000 additional cm² and let's round the total estimated surface area to 21000cm².

The next measure we need is the coverage of each photon irradiance estimate. We shoot 10000 photon on 21000cm² surface. That means that we will get approximately 1 photon per 2.1 cm². And since we use 100 photon samples for each irradiance estimate, each photon irradiance estimate will cover an average of 210 cm².

With this estimated photon irradiance coverage, we can estimate the sample size in this way : The radius of a circle covering a 210 cm² area is SquareRoot(210/Pi) which gives 8.18 cm. And since the sample area is given in 1/100th of cm, we get get a sample area of 818.

Recap

Given a room where W is the width, H is the height and D is the depth,

Scene Area = (W*H*2) + (W*D*2) + (H*D*2) + Additional object areas.

Irradiance Coverage = Scene Area * Photon Samples / Number of Photons.

Estimated Sample Area = SquareRoot( Irradiance Coverage * Pi ) * 100.

Steffen Gross calculate surface plugin

Steffen Gross have programmed a plugin that will calculate a given scene total surface area. Here is a short description of its usage:

  • Plugin is only for A:M V11 and V11.1 (PC of course)
  • Start the plugin from the chor , the chor MUST be in the Frontview (Numpad-2), otherwise you get false results for the total surface.
  • You can change all inputfields, but hit"Recalculate" after changing them to get the correct sample area.
  • The changed values are stored in the corresponding properties in the chor after hitting OK , Cancel return the plugin without any changes.
  • Use it at your own risk ....