photon map Illumination

This tutorial explains how to use photon maps to add indirect illumination into an animated walk through in a static scene.

Tutorial level: Advanced

An example shot from the photon map illuminated scene

1. Load the well known Sponza Atrium reference scene from the Internet. We recommend using .3ds format; it imports all textures automatically.

2. Start Realsoft 3D and import the atrium scene. Use the triset import option; it is very suitable for the scene. Select all imported trisets and apply the Auto Smooth tool with, say, a 30 degree limit angle.

3. The imported scene should already include a point light, which could be used directly, but you can save some rendering time by creating a spot light to the same location, pointing down to the atrium and enclosing the whole building inside its cone. Then delete the original point light.

[Note] Note
If a scene includes lights in a close range (a lamp in ceiling etc), we recommend using the physically correct Distance Squared falloff type. In this scene, the light is relatively far away from the building, and the falloff type is not important.

4. We will next consider some important controls for the photon map computation. Photon mapping obeys the same rendering settings as the usual image rendering. Go to the Render Settings tab of the select window and pick a setting object, say 'Quality over Speed'. Open the property window and go to the 'Ray tracing' tab. Set recursion depth to a fairly high level, say 15 bounces or so. The value defines the maximal number of photon bounces before the tracing is terminated. Recursion threshold should be quite high, for example 200 units (=0.20). Typically, a diffuse surface reflects less than 80 % of incoming photons. Note that surface's diffuse color defines the main reflectivity, but the recursion threshold just adds a handy maximum limit. Thanks to it, you do not have to edit all colors, materials and textures of the scene to achieve a realistic diffuse reflectivity.

5. Other ray tracing settings are not relevant for photon mapping, but the 'Misc' tab has some important options. So switch to the rightmost tab of the property window. It includes a dedicated area of photon mapping settings. Make sure that 'Auto photon map' is not set (we will use a static photon map instead of dynamic map generated at each rendering cycle). Set first a suitable value to the KPhotons field, say, 1000. This will trace hit positions of approximately one million photons. Sampling rate can be 100 and Noise Reduction can be set to 1.

6. Close the property window and go to the 'Light Sources' tool tab. Activate the Photons tool. Make sure that the edited render settings (Quality over speed in our example case) is selected in the Settings gadget. Include Direct Photons option should be left cleared; it is faster to compute direct illumination using light ray tracing. Then click Accept.

7. Wait until the tool finishes the computation. A new object appears in the hierarchy; it is a photon map, a special kind of light source. Now you can edit its brightness, sampling rate and other settings in the tool control bar, and render test images to see how it affects the scene. You will probably have to increase the Brightness value of the photon map considerably, because only small part of photons will reach the dark corners of the atrium. If the image seems to include only direct illumination, set a dramatically higher Brightness value for the map, say, 5000. After a couple of tests, you should be able to find a proper Brightness level.

8. You can see the actual stored photon-surface collision count from the toolbar when the photon map is selected. The atrium scene is not very complex, but detailed illumination cannot be achieved without several millions of photon hits. Unfortunately high density photon maps require plenty of RAM memory, so one has to be careful when setting the KPhoton value. A rough rule of thumb could be that 1 GB of RAM is enough for about 5 millions of photons (considering that there is also other kind of geometry in the scene, requiring its own part of RAM resources).

9. After the test round, we will create the actual high quality photon map. Delete the test photon map. Open the property window and select again the render settings. You may increase the KPhotons value to match your computer resources and scene requirements as instructed above (e.g. to 10000 KPhotons).

This time we will also use the Noise Reduction option. As the name indicates, it will improve the quality of the photon map, so that sharper, less noisy illumination can be rendered using the map. Unfortunately the noise reduction process is very computation intensive. To estimate roughly what kind of value you can use, multiply the computation time of the first photon map with the noise reduction value and the KPhotons increment factor. If the test map was created in 5 seconds, a new map with 10 times higher KPhotons value and Noise Reduction value 100 will take 5*10*100 seconds = 5000 s = about one and half hours. It is quite a long time, but fortunately the computation will be done only once. All animation frames will use the same map and render very quickly.

10. Create a new photon map with the new high quality settings. When the map is ready, save the scene to ensure that the valuable quality photon map will not get lost accidentally. The saved file will also act as a backup data for the step 12 of this tutorial, which will change the map permanently.

11. Test render images with the new map. The higher Noise Reduction you used, the lower Sampling (=render time photon averaging) rate is required. If the Noise Reduction value was 10, Sampling may have to be 1000 to smooth out noisy illumination, whereas Noise Reduction 100 might work well with Sampling rate of 200.

12. When a suitable Sampling rate is found, it is time to bake the filtered indirect illumination into the map itself. Select the map and click the Filter tool button in the tool bar. The tool computes the indirect illumination at photon positions and stores the illumination into the photons. For the sake of memory efficiency, photon's original illumination is not backed up in RAM, but the new filtered illumination overwrites it. When the filtering is ready, Sampling rate decreases automatically to a very low value (default = 6). Now the photon map renders very quickly. Save the scene with the finalized photon map.

13. Create a large sky dome sphere around the scene. Assign a light blue illumination and black diffuse color to it. Make sure the spotlight is inside the sky dome. Insertion of the sky dome was deliberately left this late, because we did not want it to interfere with the photon map computation. It is not useful to store photons on the evenly lit sky surface - it would simply be waste of RAM memory.

14. Add a camera object inside the atrium and animate it to move around. Open the File rendering window. Configure suitable settings and enable the Walkthrough rendering mode. Render the animation to a suitable format.