Shadow Maps

Shadow mapping is a technique that generates fast approximate shadows. It can be used for fast previewing of models or as an alternative to the more accurate (but also more costly) ray marching based approach in scenes where accurate shadows are not required. Shadow maps are particularly efficient when a scene is rendered several times without changes in the shadows (for example an animation where some of the lights and shadow-casting objects are not moving).

A shadow map is a fast depth buffer rendering of the model as seen from a light source. This means that each pixel in a shadow map contains information about the distance to the nearest object in the model in a particular direction from the light source. This information can be used to compute shadows without using shadow rays to test for occluding objects. The shadow computation is based only on the depth information available in the shadow maps. For fast previewing of scenes, shadow maps can be used in combination with scanline rendering to produce fast approximate renderings with shadows - without using any ray marching.

Two different kinds of shadows can be produced with shadow maps: sharp and soft (blurry) shadows. Sharp shadows are very fast, and depending on the resolution of the shadow map they will approximate the result produced with simple ray marching. Soft shadows are produced by distributing one or more samples in a region of the shadow map. This technique produces soft shadows everywhere and is not as accurate as the ray marching based approach for computing soft shadows but is much faster.

Shadowmaps normally store the halfway point between the first two shadow intersections, which is called the "Woo trick". If there is no second hit, 0 (infinity) is stored because no shadow can exist, since there is no second object that the shadow could be cast onto. However, the second hit can come from a previous render whose shadowmap we are merging, so 0 (infinite) depths can occur in both the old and the new shadowmap because both saw only one hit, but together that's two hits and there should have been a nonzero depth. Hence, shadowmap merging is fundamentally incompatible with the Woo algorithm.

mental ray also implements a shadowmap algorithm based on explicit shadowmap bias values. The bias is a world-space distance set in the options block or in light source definitions. The light setting overrides the global setting in the options; the global value applies to all lights that do not have their own bias. A bias of zero means "no bias"; a light that gets a non-zero bias uses the bias algorithm while all others use the Woo algorithm. Bias values should be chosen smaller than the smallest distance between a shadow caster and a shadow receiver, but not too small to avoid shadow acne due to numerical inaccuracy. The bias algorithm stores the depth of the first intersection directly, after adding the bias value, without looking for a second intersection.

Shadowmaps that are saved to a file store the bias value separately, without applying the bias to actual depths from the light. The bias is applied during lookup only, not during storage. When the shadowmap file is later loaded from disk, the bias of the new scene is used, not the one potentially stored in the shadowmap. As an exception, if the shadowmap file contains a bias but the new frame does not (because it uses the midpoint Woo algorithm), the old file is adjusted by its bias upon loading. This allows merging biased and Woo maps, although this is not recommended.

To set a bias in a light or the options in the scene file, use the statement shadowmap bias N. The options bias can also be set with the command-line argument -shadowmap_bias N.

Standard shadow maps always assume that shadow-casting objects are fully opaque, and never call shadow shaders. mental ray also supports an advanced detail shadowmap algorithm that collects and stores more information about shadow-casting objects. It combines features of standard shadow maps and ray traced shadows. It will call shadow shaders if present, thus capturing even custom shadowing effects. Since shadow shaders return transparencies, detail shadowmaps do not store a single depth value, but a sequence of depth values together with the light transmission coefficients at each depth.

Typically, detail shadowmaps need lower resolution settings than standard shadowmaps, since they may take more samples per pixel. Even with less resolution, detail shadowmaps tend to be more expensive to compute than standard shadowmaps because of the shadow shader calls. They may even be more expensive than ray traced shadows. However, these costs may pay off when reusing a map over several frames of an animation. They may also be more efficient for motion blurred shadows with regard to time and memory resources compared to full ray traced shadows.

The file format used to store detail shadow maps is incompatible with the file format used to store regular shadow maps. Especially, it is storing information in tiles, and only those tiles are computed which are used during rendering. New tiles may be added on demand. Therefore, such files are not directly displayable with standard image viewers or editable with common paint programs. Detail shadowmap files tend to be larger than regular shadowmap files since more information is stored per pixel.

See also Known Limitations.

Copyright © 1986, 2015 NVIDIA ARC GmbH. All rights reserved.