How to Set up a Global Photon Map
Photon mapping is a method which calculates illumination information about a scene by emitting light particles, called photons, from light sources. Photon maps can be used to create realistic caustics, multiple-bounce global illumination effects, and volume shading. With photon maps, chrome can bounce light onto walls and glass balls can cast hot spots.
Photon mapping works by casting light particles, photons, from light sources into the scene. The path a photon takes is traced from its light source; the lights "push" the photons into the scene. Photons that hit objects behave according to the surface properties of the object they hit (passing through glass, bouncing off chrome, scattering off of matte, while also losing some intensity with each transaction). Each time a photon hits an object that illumination info is recorded, and at the end all of the photon values are used to estimate average light contributions. The information collected from the photons is stored in a photon map. Photon maps are calculated in a pre-pass, similar to shadow maps.
There are several varieties of photon maps, which serve different purposes: caustic photon maps, global photon maps, volume photon maps, etc. PRMan 11 provides support for caustic photon maps and global photon maps (only shader stand ins, and not the shaders themselves, are evaluated). Other photon maps are not currently implemented, but will be implemented in PRMan 12.
Photon maps provide an efficient solution for creating realistic images which rely on the transport of light off of and through multiple surfaces. Melville might as well been talking about the finer points of photon maps when he wrote:
But high above the flying scud and dark-rolling clouds, there floated a little isle of sunlight, from which beamed forth an angel's face; and this bright face shed a distant spot of radiance upon the ship's tossed deck, something like that silver plate now inserted into Victory's plank where Nelson fell. "Ah, noble ship!"
Herman Melville, Moby Dick
(Note: The volume photon map effects that Melville describes will be available in PRMan 12.)
Photon maps are particularly efficient when multiple bounce effects are required. For instance, caustics effects are only feasible through the use of photon maps. In PRMan 11, photon maps are most useful for caustics and instances where multiple-bounce global illumination is necessary.
Photon Map Globals This panel controls aspects related to photon map generation and usage. Photon maps are computed in a separate rendering pass and are then used to calculate caustic and other global illumination effects. Shading Model - Specifies a simplified shading model to employ
when tracing photons. If empty, the shader will be analyzed to determine
photon scattering. The shader analysis phase is slower than the simplified
shading model but captures complex shader-specific behavior. This value
acts as the scene default and you can override this value on a
per-primitive basis via the Slim Ensemble. |
|
Photon Maps The generation of photon maps is the same for both caustic and global photon maps. |
|
Enable
Photon Emission Checking this box causes a light source to emit photons. All lights that should emit photons in a scene should have this parameter enabled. |
|
Photon
Map Generation Only one photon map needs to be generated for a scene, even if multiple lights are emitting photons. All photons from all lights will be included in the photon map generation.
|
|
Viewing Photon Maps "it" can display photon maps, which can be useful for debugging problems. Use "it" to load up a cache file like any other image. You can also use the sho utility to display cache files via the command line. The following example tells sho to display a caustic photon map: sho scene.example.icf Sho can display global photon maps in two modes: point or disk, as shown in figure A & figure B. The mode is stipulated by appending ",n" to the filename where n. ",0" specifies point display. ",1" specifies disk display. The following example displays a global photon map using disk: sho global_photon_map.0001.pho,1
|
|
When a photon hits a surface it collects information about it, surface color, opacity, and other material properties. These properties can be customized on a per shader basis using the Slim Ensemble. The following explains how these properties are configured.
Photon Coloring The color that a photon inherits when hitting a surface is controlled by the color value provided in the ensemble. That parameter is displayed in the image on the right.
|
|
Surface Type
Specification How a photon reacts when it hits a surface depends on that surface's material properties. That value is set in the Ensemble. Currently surfaces can behave like one of six materials when struck by a photon: matte, translucent, chrome, glass, water, and transparent. (In the future, regular surface shaders will also be able to control
photon scattering. Then there will be a choice between the flexibility of
regular shaders vs. the efficiency of the built-in shading models.) |
|
Photon Bounce Depth Also note that the global settings "Max Specular Depth" and "Max Diffuse Depth" that are usually used to control maximum ray depths are also used to control maximum photon depths. |
In computer graphics, we use the term caustic to denote light that has been specularly reflected or refracted onto a diffuse surface. Examples of real life caustics are the shimmering waves of light at the bottom of a swimming pool or the heart-shaped reflection inside a coffee-cup.
In order to get a caustic effect in PRMan, the scene needs to have both specular and diffuse objects, and the light sources have to be set up such that light from the light sources hit a specular object and is then reflected or refracted onto a diffuse object.
Caustics are computed in two passes. In the first pass, photons are emitted from the light sources, traced through the scene, and stored in a caustic photon map. The second pass is rendering, when the caustic photon map is used to compute the caustic color at different shading points.
When photons strike an object how they react depends upon that surface's particular material properties. The Slim Ensemble allows these properties to be defined on a per shader basis (overriding the scene defaults). Both the surface properties (glass, water, chrome, matte, etc) and the color of the caustic effect are defined in the ensemble. Note that at this time surface shaders are not evaluated, only a predefined group of surface primitives may be associated with objects. Come PRMan 12, photon maps will be able to evaluate surface shaders. This will allow for new levels of realism, which makes one almost think that Melville was really talking about caustic surface shader evaluation in PRMan 12 (and not Death) when he wrote:
it maketh a marvellous difference, whether thou lookest out at it from a glass window where the frost is all on the outside, or whether thou observest it from that sashless window, where the frost is on both sides, and of which the wight Death is the only glazier.
Herman Melville, Moby Dick
Seven steps to caustics with the Slim Spot Light:
Want more? For an in depth caustics tutorial see RAT
Tutorial: Caustics.
Caustics Generating a caustic map in MTOR requires familiarity with the following: |
|
Proper Light Configuration
First, lights must be set to emit photons. Second, lights must have the proper falloff. Spot and point lights must
have squared falloff. Directional lights must have no falloff. This is because photons from a point or spot light naturally spread out
so that their density have a quadratic fall-off, and photons from solar
lights are parallel so they inherently have no fall-off. |
|
Photon Map Generation A PhotonMapCaustic needs to be wired into the "Caustics" parameter of a light source. Note that even if multiple lights are emitting photons, only one photon map is required. A single photon map will collect info from all photons emitted from all lights. Photon map generation must also be properly configured, to control the creation of photon maps. |
|
Caustic Color The color of the caustic effect is controlled in the ensemble, with the Cs parameter. The color of this parameter should match the color of the object. |
|
Surface Behavior When a photon strikes an object it reacts to that material's surface properties. That property can be set on a per shader basis via the ensemble's Shading Model parameter. |
Here's more technical information about Caustic Photon Maps
Why doesn't the caustic photon map contain any photons?
Caustics are a specular-to-diffuse effect. So in order to get a caustic, the scene needs to have both specular and diffuse objects. Make sure that the light source illuminates the specular object. Also make sure that the attributes "trace" "maxspeculardepth" and "trace" "maxdiffusedepth" are set sufficiently high for the scene (the default values are 2 and 1, respectively). It is common to set both of these values to 5 during photon tracing.
Why are there only a few photons in the photon map?
Did you specify enough emitted photons (the "emit" parameter to the hider)? Values between 100,000 and 1,000,000 are typical. If you specified a large number of photons to be emitted, but only a few of them end up in the caustic photon map, the reason is often that only a small fraction of the emitted photons hit the specular objects. You can help by guiding the photon emission better. For example, turn point lights into spot lights pointing toward the specular objects, and/or narrow the cone of the spot lights so that the cone just covers the specular objects.
Why isn't the caustic effect appearing in the rendering?
First check that the caustic photon map has the right name and actually has photons in it. Make sure that the surface where the caustic should be has a caustic or photonmap shadeop, or that it is illuminated by a caustic light. Also, note that photons from point and spot lights inherently have a square fall-off. So if the lights you use for direct illumination have linear or no fall-off, the caustic can be very dim compared to the direct illumination.
How can I reduce the noise in the caustics?
Too few photons are used to estimate the caustic. If the photonmap shadeop is used, increase the "estimator" parameter. If the caustic shadeop is used, increase the "photon" "estimator" attribute.
Why is the caustic so blurry?
Either too many photons are used to estimate the caustic, or there are too few photons in the caustic photon map. To reduce the number of photons used in the caustic estimate, decrease the "estimator" parameter of the photonmap shadeop, or decrease the "photon" "estimator" attribute (if the caustic shadeop is used). To increase the number of photons in the caustic photon map, either increase the number of emitted photons with the "emit" parameter to the photon hider, or increase the fraction of photons that get stored (for example by reducing the cone angle of spot lights --- see item 2 above).
Where did all these "polka dots" come from?
This can for example happen if the intensity of the caustic is set much higher than it should. Essentially, the polka dots are little regions around sparsely scattered photons. Usually the dots from sparse photons are so dim as to be invisible, but if the caustic color is multiplied by some very high multiplier, the dots can become visible. Either reduce the multiplier or increase the "estimator" to smooth the caustics.
Photon map global illumination
To get multiple bounce indirect illumination effects in a reasonably efficient way it is necessary to use photon maps. With the photon map method, we get multiple bounces essentially for free, since they are pre-computed in the photon map. However, indirect illumination requires costly single bounce hemispherical sampling, even when used with photon maps. (Photon maps by themselves do not provide a high enough sampling. Hemispherical sampling is still required.) Photon maps do save time by pre-computing multiple-bounces and running surface shaders, but since hemispherical sampling still occurs, single-bounce indirect illumination with photon maps is generally not necessarily faster than single-bounce illumination without photon maps.For indirect illumination effects, a single bounce is generally sufficient. On the rare occasion that multiple bounce effects are required, global photon maps will provide a definite benefit, but for the general case of single bounce indirect illumination, photon maps are not necessary and will also create lower quality color bleeding and fickle lighting requirements.
The benefits of photon maps are mainly to be gleaned for caustic effects, but for multi-bounce global illumination photon maps may still play a valuable role.
Global Photon Limitations
There are also some significant drawbacks to using global photon maps with
indirect illumination:
Here is the basic setup for creating a global photon map with an indirect
light.
- Create an indirect light shader. Connect an Indirect Illumination node and enable photon map generation. Attach it to a Maya spot light.
- Indirect illumination calculations occur only within the area defined by the cone.
- The indirect shader requires other direct light in the scene. Indirect casts no light itself!
- Create a spot light shader, enable emit photons. Attach to a different spot light.
- Make the falloff for spot and point lights "squared," use no falloff for directional lights, and set an appropriate intensity.
- In the Render Globals Photon Mapping Tab add the name of the Global Photon map that is generated by the indirect spot light in the Global Map field.
- Modify the ensembles attached to objects to specify the photon shading model. This will be used in conjunction with the Ensemble color to determine how photons interact with an object.
- Render. Tweak. Repeat.
Global Photon Maps Generating a global photon map in MTOR requires familiarity with the following: |
|
Proper Light Configuration
Lights must be set to emit photons. Second, lights must have the proper falloff. Spot and point lights must have squared falloff. Directional lights must have no falloff. (This is because photons from a point or spot light naturally spread
out so that their density have a quadratic fall-off, and photons from
solar lights are parallel so they inherently have no fall-off.) |
|
Photon Map Generation To generate a global photon map, an Indirect Illumination function needs to be wired into a shader. It can be wired into a light shader, such as the Indirect Light, or into a surface shader, such as Swiss Army. Note that even if multiple lights are emitting photons, only one photon map is required. A single photon map will collect info from all photons emitted from all lights. |
|
Photon map generation must also be properly configured to control the creation of photon maps. |
|
Material Color The color of the global photon effect is controlled in the ensemble of the surface shaders the photons hit with the Cs parameter. The color of this parameter should match the color of the object. |
|
Surface Behavior When a photon strikes an object it reacts to that material's surface properties. That property can be set on a per shader basis via the ensemble's Shading Model parameter. |
|
Reference the Global Photon Map In the Render Globals Photon Mapping Tab add the name of the Global Photon map that is generated by the indirect spot light in the Global Map field. This is not automatic, which requires you to add the name written by the photon map generator. |
Here's more technical information about Caustic Photon Maps.
The caustic photon map only contains photons that hit a diffuse surface coming from a specular surface. The global photon map contains all photons that hit a diffuse surface (no matter where they came from). In other words, for a given scene, the photons in the caustic photon map are a subset of the photons in the global photon map. Another difference is that the photons in the global photon map have pre-computed radiance values stored with them (this is an optimization to speed up the rendering of indirect illumination).
I'm using a global photon map, but my picture shows no indirect illumination. Why?
First check that the global photon map has the right name and actually has photons in it. Make sure that the surfaces where the indirect illumination should come from have a globalmap attribute. Also, note that photons from point and spot lights inherently have a square fall-off. If the lights you use for direct illumination have linear or no fall-off, the indirect illumination can be very dim compared to the direct illumination.
I'm only interested in one bounce indirect illumination. Should I use a photon map or not?
For one bounce indirect illumination, for most every case, don't use photon maps. Both methods require the same amount of hemispherical sampling, and the only difference is what happens when indirect samples hit a surface. For the photon map method, the photon map color is referenced, but for standard indirect illumination, the surface shader is evaluated instead. Each approach has its advantages and disadvantages, but there are also some significant drawbacks to using global photon maps to keep in mind:
Pixar Animation Studios
|