How to Set Up Indirect Illumination
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 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.
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.
|
|
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
In a surface shader:
- Create a Swiss Army shading model. Connect an Indirect Illumination node to the "Indirect Diffuse" parameter to enable hemispherical sampling.
- Specify the name of the irradiance cache in the RenderMan Controls, or override on a per-ensemble basis.
- Render. Tweak. Repeat.
Using an indirect light shader:
- 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!
- Specify the name of an irradiance cache in the RenderMan Controls, or on a per-ensemble basis.
- Ensure there are normal lights in the scene. If not, create a spot light shader. Attach to a new spot light.
- Render. Tweak. Repeat.
Hemispherical SamplingSoft 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 |
|
Indirect Vs. Direct Light Comparison |
|
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 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 Samples Trace Subset Max Distance |
|
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. Motivation 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:
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 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
Refer to the tutorial Baking Occlusion
for more info. |
|
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.
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:
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
|