MTOR Indirect Illumination Overview

Table of Contents


How To's

Global Controls

How to Set Up Indirect Illumination

Indirect Illumination in MTOR

Irradiance Cache Files

Indirect FAQ



Indirect illumination is an effect that utilizes hemispherical samples to create subtle shadowing effects. Indirect illumination may be used to create such effects as global illumination, color bleeding, and image based lighting (with full support for high-dynamic range images). The technique of image based lighting relies upon calculating the illumination of a point on a surface by taking many hemispherical samples (1024 samples per point is not uncommon for high quality). 

Indirect illumination can be expensive to render, and so Pixar's RenderMan allows these calculations to be "baked" for reuse. This indirect illumination data is stored in what is called an irradiance cache file. 

How To's

How can I wire Indirect Illumination into a scene?
Please refer to How to Set Up Indirect Illumination.

How do I create a *.icf file with MTOR and Slim?
Check out Generating Irradiance Cache Files.

How can I look at a 3D cache file?
Take a look at Viewing Irradiance Cache Files.

Global Controls

The Irradiance Cache Sub-Tab

This panel controls aspects related to irradiance caching. The irradiance cache can be used to accelerate global illumination calculations and can be stored in irradiance cache files for future reuse. You can have any number of independent irradiance cache contexts to override the scene-wide default established here.

Max Error - An error metric to control quality/speed tradeoff for indirect illumination. Larger numbers result in a coarser approximation but speed up the rendering. Set this value to 0 if you wish to force a recalculation of global illumination at every point. This value acts as the default and you can override this value on a per-primitive basis via the Slim Ensemble. The default value is 0.5.

Max Pixel Distance - A secondary error metric to control quality/speed tradeoff for indirect illumination. Larger numbers result in a coarser approximation but speed up the rendering. Set this value to 0 if you wish to force a recalculation of global illumination at every point.  This value acts as the default and you can override this value on a per-primitive basis via the Slim Ensemble. The default value is 20. Only in very unusual circumstances does this value need to be changed.

Cache File - An irradiance cache file is used to accelerate the indirect diffuse calculations. During image generation, the renderer continuously updates the various internal irradiance caches and these results can be reused - either to speed up test renders, or to "bake" the irradiance calculations once and for all for a final model or scenario. As your set and lighting design begins to settle out, you can save lots of rendering time by setting the file mode to Read-Write or Read-Only. Refer to the help for Irradiance File Mode for more. 

Cache File Mode - The file mode associated with the Irradiance Cache, which controls how a cache file is used. When set to Ignore, the no cache files are read and no cache is saved to disk. When set to Read, cached data will be referenced. When set to Write, any existing cache file will be ignored, effectively starting with a blank slate. The state of the cache will be written to the file when rendering completes. 



The Irradiance Cache Sub-Tab

Ensemble Overrides
Many of the settings found in the Irradiance Cache Sub-Tab can be overridden on a per shader basis, via the controls found in the ensemble. These controls allow you to assign ray tracing behavior on a per-surface basis, overriding the scenes defaults and independent of other surfaces. 

The ensemble's ray controls default to the global settings defined in MTOR's Rays Control panel. By explicitly setting values for these parameters the ensemble will override the global settings. For more information about the ensemble ray overrides refer to: The Ensemble's Ray Tracing Controls

How to Set Up Indirect Illumination

In a surface shader:

  1. Create a Swiss Army shading model. Connect an Indirect Illumination node to the "Indirect Diffuse" parameter to enable hemispherical sampling.
  2. Specify the name of the irradiance cache in the RenderMan Controls, or override on a per-ensemble basis.
  3. Render. Tweak. Repeat.

Using an indirect light shader:

  1. Create an Indirect Light Shader. Connect an Indirect Illumination node. 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!
  2. Specify the name of an irradiance cache in the RenderMan Controls, or on a per-ensemble basis.
  3. Ensure there are normal lights in the scene. If not, create a spot light shader. Attach to a new spot light. 
  4. Render. Tweak. Repeat.

Indirect Illumination in MTOR

Hemispherical Sampling

Soft Contact Shadows via Occlusion

The effect of soft contact shadows can be generated by gathering occlusion information to determine the amount a point is obscured by other surfaces. This occlusion information can be gathered by casting many hemispherical samples from a given surface point.   

However, computing occlusion at every shading point on a surface is very time consuming. Fortunately, we can often average hemispherical sample data in order to accelerate the rendering. PRMan's efficient hemispherical sampling algorithm only samples at points where it has to; at most locations it can just average the indirect illumination value. The Max Error setting determines how far a hemispherical sample can be used. If Max Error is 0, the occlusion is computed at every shading point. If Max Error is very high (like 1000), occlusion is only computed at the corners of micropolygon grids and interpolated everywhere else. The default value for maxerror is 0.5.

Indirect Illumination can be built into surface shaders or generated by indirect light shaders.

Example Occlusion Shader
Here's an example of a Ray Traced Occlusion shader built using Slim.

Indirect Vs. Direct Light Comparison
The two images below show the difference between indirect and direct lighting. The scene has one light, which doesn't cast shadows. The only difference between the two images is the addition of indirect illumination. Indirect illumination provides many subtle shading effects but these effects have a high cost at render time. Subtle shadows can also be faked, and while this takes more setup time during lighting and shading, the images will render much faster. The choice to use indirect illumination, or to fake it, should be a conscious decision. 

Indirect Illumination

The scene has one light source, without shadows. 
The shadows and chiaroscuro are entirely generated by hemispherical sampling. 
Direct Light

The same scene with hemispherical sampling disabled.
This scene would require additional lights and shadows to simulate the image on the left, but after the initial setup, it would render much faster. 
Indirect Via Surface Shaders

Hemispherical sampling can be wired directly into any shader that performs indirect illumination calculations. Swiss Army is a good example of a shader that accommodates this. To enable indirect illumination, simply wire an Indirect Illumination to the "Indirect Diffuse" parameter. 

Any surfaces attached to the shader will cast hemispherical samples. The samples can be controlled by the indirect illumination node and adjusted on a per shader basis. 

Note: this method does not require an indirect light.  



Indirect illumination plugged into a surface shader

Indirect Via Light Shaders

The Indirect Light is provided to deliver indirect diffuse illumination to surfaces. Any diffuse surface which falls in the area "illuminated" by the light will perform hemispherical sampling of the scene. The indirect light does not provide any direct light itself and requires other normal lights in the scene, whether they are spots, directionals, or points.  

This method of indirect illumination affects all surfaces equally, and as such it is the least flexible and most expensive option. In contrast, wiring indirect illumination into surface shaders, like Swiss Army, provides a finer level of control on a per shader basis and also makes indirect illumination independent of the lighting setup in any particular scene. A benefit (and sometimes a drawback) of the Indirect Light is that any shader with a diffuse value will perform hemispherical sampling . . . and not just shaders that explicitly call indirect illumination. 

Notice that the indirect illumination can be controlled by the Indirect Illumination function.


Indirect Illumination Parameters

Make Photon Map
This usually should be disabled . . . for most single-bounce hemispherical calculations. When photon map generation is enabled, the Indirect Illuminance node will refer to a photon map when casting hemispherical samples. For more information see: Global Photon Maps. However, in the general case this should be disabled. For a discussion on when to use photon maps see the Indirect Illumination FAQ at the bottom of the page. 

Provides an additive “floor” for the indirect illumination.

Indirect Strength
Provides a multiplicative effect for the indirect illumination.

Filters the coloration of the indirect illumination effect.

Color Bleeding 
Enable this to calculate color bleeding effects. For faster rendering, disable this to get indirect occlusion (shadowing) only. When enabled, each hemispherical sample that hits a surface will run the shader. Since running shaders every time a sample hits a surface can be expensive, color bleeding can be disabled so that only indirect occlusion is evaluated (whether or not a sample hits a surface or not) which is much cheaper. However, if this parameter is disabled, then the Max Distance should be set to a reasonable number.  

Specifies the number of samples for the gathering of indirect illumination. Because the region of interest is so large, we must gather a comparatively large number of samples - and this is why these effects are so expensive. Typically, you’ll need at least 256 samples to achieve high quality images.

Trace Subset
For more info see Trace Sets.

Max Distance
For more info see Max Distance

Environment Map
Specifies the name of an environment map to consult when samples fail to intersect geometry. When a ray doesn't hit any surfaces it can sample an environment map. This setting can be used quite effectively with Max Distance. 


Indirect Illumination Parameters


Indirect Illumination  -  32 Samples

Indirect Illumination  -  256 Samples




Irradiance Cache Files

Irradiance Cache Files
Irradiance cache files provide a method of storing hemispherical sampling data. This indirect illumination data can be stored globally, for an entire scene, or it can be selectively stored for particular objects, on a per shader basis. Once generated, an irradiance cache file can be reused, dramatically decreasing render times.   

MTOR provides two levels of control over generating cache files, globally through the RenderMan Globals, or on a per shader basis via the Ensemble. Once a cache file is generated it can be referenced from frame to frame in an animated sequence or re-used by models that are imported into other scenes. Data can be reused as long as the relevant object(s) doesn't move. If the object moves the indirect illumination data must be recalculated. MTOR provides several ways of reusing cached data.  

Sampling the hemisphere above a point is a very expensive operation since it involves the tracing of many rays, many shader evaluations, etc. This is the reason we interpolate indirect illumination between shading points. We can also reuse computed indirect illumination from one frame to the next in animations. This is often referred to as "baking" the indirect illumination. So if some objects don't move in an animation, and their indirect illumination doesn't change significantly, we can compute the indirect illumination on these objects in the first frame and then reuse the computed indirect illumination in all the following frames.

Reusing computed indirect illumination from frame to frame is useful to speed up occlusion, environment illumination, color bleeding, and photon map global illumination.



Generating Irradiance Cache Files

The use of a cache file requires two main things:

  1. A cache file name, which is entered the "Cache File" globals. The default "[irradiancecache global]" creates a cache file called global.icf in rmantex. Alternatively, as shown on the right, a cache file can be explicitly set on a per shader basis (via the Ensemble or special Slim caching nodes, like Occlusion Map). To reference a different cache file every frame use the syntax, rmantex/foo.$F4.icf.
  2. A cache file mode, which tells the shader how to read or write indirect illumination data.

As it mentioned before, the use of a cache file can dramatically speed rendering within a single scene. During a single render pass, all samples that hit a previously cached point will reuse that data. This can have a dramatic effect on render times. And remember, unless a cache file name is explicitly provided, no cached data is written to file and is discarded once the rendering is completed.

The Cache File
The cache file is stored in the rmantex directory of the current project, as an *.icf (irradiance cache file), *.ocf (occlusion cache file), or other potential format depending on the type of data stored. 

You can give any arbitrary name to a cache file, and it will be stored in the directory relative to your project. For instance "rmantex/foo.icf" would create a file called "foo.icf" in the "rmantex" directory. 

The cache file can be specified globally for the entire scene, in the RenderMan Controls, or on a per Ensemble basis (as shown on the right). The advantage of using the Ensemble is that it allows you to explicitly associate caches with the geometry that the Ensemble is attached to. (Multiple Ensembles can reference the same cache file.)  

Cache File Mode
To use an irradiance cache file effectively, the appropriate mode should be selected, and that all depends on what you're trying to do, generating a cache file or reusing one. When writing out a new cache file, use "Write". When re-using a cache file from job to job, either "Read". (It's somewhat analogous to generating and reusing computed maps.)    

Performs hemispherical sampling, but does not write, read or store cache values.

Use this setting to reuse baked indirect illumination. A pre-calculated icf file is used for all indirect illumination data, no additional hemispherical calculations are performed. Reusing baked data with "Read" is the fastest, most efficient, means available to render indirect illumination effects, but the baked data must be high quality, the baked icf file must contain sufficient samples of the surfaces.

All data in any existing caches will be overwritten, and a new cache will be saved. 

Refer to the tutorial Baking Occlusion for more info.


RenderMan Globals Irradiance Cache File Controls


The Ensemble's Irradiance Cache File Overrides

Viewing Irradiance Cache Files

"it" can display irradiance cache files. 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 cache file:

sho scene.example.icf

An *.icf file can also be displayed in 3d, using the PTViewer ultility. From the prompt:

ptviewer scene.example.icf


General Strategy
Indirect illumination becomes more practical in the cases where the hemispherical sampling can be cached and reused. For instance, irradiance caches can be effectively used in conjunction with complex objects which remain stationary in a scene, like buildings, broken terrain, or a room. The indirect illumination calculations can be performed once and then reused for subsequent renderings.  Ensembles can be used to generate irradiance cache files for these objects, allowing the complex objects to be imported or referenced in other scenes and reuse cached data. 

Here's more technical information about Indirect Illumination.

Indirect Illumination FAQ

I'm only interested in one bounce indirect illumination. Should I use a photon map or not?

For one bounce indirect illumination, in most every case, photon maps are not necessary. 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:

  1. Currently, photon maps are not able to run surface shaders, only shader primitives, which also limit their use for effects like color bleeding. This means that color bleeding effects from a surface with a textured shader can only bleed a constant color, and not bleed the varying values of the texture. Color bleeding with standard indirect illumination, without photon maps, does not have this problem, since the shader is evaluated in that case. 
  2. For proper photon map generation, lights that emit photons must have the proper falloff. Spot and point lights must have squared falloff. Directional lights must have no falloff. Note: This is not a requirement of normal indirect illumination, and might mean that non-trivial time must be spent re-lighting scenes.

To color bleed or not to bleed, that the question.
In the case of color bleeding, when a hemispherical sample is cast into a scene and hits a surface, the surface shader is run. By running the surface shader the color of the point is returned and averaged into the entire collection of hemispherical samples, which provides color bleeding. The effect of color bleeding is accurate and can create some subtle lighting effects, but running surface shaders every time a sample hits a surface carries a substantial overhead. There is a cheaper alternative, disabling color bleeding. This method merely checks for occlusion information (and doesn't run the shaders associated with surfaces). Checking for occlusion won't provide color bleeding but it will create subtle shadowing effects. When using the occlusion based method, remember that any given hemispherical sample will either hit or miss (ignoring distance) and an appropriate Max Distance setting is crucial for efficient shadowing. For occlusion, the Max Distance setting should only be as far as the objects in close proximity, which will most greatly affect the shadowing.      

Does one surface primitive render faster than others? 
Tracing polygons is often faster than tracing NURBS or subdivision surfaces. This difference can sometimes be dramatic for computationally expensive operations, like hemispherical sampling. By converting the NURBS and subdivs in a scene to polygons, you may see substantial speed increases at render time. This means, however, the less savory aspects of polygonal topology must be dealt with (displacement continuity issues, tessellation, and other particularly polygonal artifacts). Note that particularly dense polygonal meshes can trace much slower than their NURBS or subdivision counterparts, and while the amount of acceleration can vary on a scene by scene basis, sometimes it is worth trying. 

Should I use shadow maps or ray traced shadows with indirect illumination?
When using color bleeding, shadow maps are more efficient than ray traced shadows, especially in the case of blurry traced shadows. Ray traced shadow calculations occur at render time and will be performed whenever a hemispherical sample hits a surface point that falls in a traced shadowed area. (The surface shader is run, which causes the light shaders illuminating the object to be run.) Multi-sampled ray traced shadows can have a large impact on the speed of indirect illumination, since each hemispherical sample that hits a surface will run the surface shader and the light shaders effecting that surface. So, if the light shaders are casting mutli-sample ray traced shadows, each hemispherical sample will cause the recalculation of the ray traced shadow samples. Basically, shadow maps are more efficient for indirect illumination.   

I've set my Max Diffuse Depth to "3" and rendering is much longer. Why? 
The Max Diffuse Depth Setting limits the number of bounces for indirect illuminance relative to the associated primitive. A sensible setting for this parameter is "1" . . . unless global photon maps are being generated. Photon maps are efficient at calculating multi-bounce illumination. Standard indirect illumination is not. Standard indirect illumination (without photon maps) takes a brute force approach to calculating multi-bounce illumination. Take the case of a hemispherical sampling of 256 samples, each time a sample bounces, another 256 samples are cast. For a single bounce from a single point, 256 samples are cast, total. For a double bounce, each sample causes another 256 samples to be cast from wherever each of those first 256 samples hit . . . for a whopping total of 65,536 samples per point. For three bounces, the samples add up to 16,777,216 samples per point. Multiple bounce indirect illumination can rapidly become incomputable. Beware. This is where global photon maps serve their purpose. 



Pixar Animation Studios
(510) 752-3000 (voice)   (510) 752-3151 (fax)
Copyright © 1996- Pixar. All rights reserved.
RenderMan® is a registered trademark of Pixar.