3D graphics eBook - Course Materials Repository
3D graphics eBook - Course Materials Repository
3D graphics eBook - Course Materials Repository
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Shadow mapping 180<br />
Drawing the scene<br />
Drawing the scene with shadows can be done in several different ways. If<br />
programmable shaders are available, the depth map test may be performed by<br />
a fragment shader which simply draws the object in shadow or lighted<br />
depending on the result, drawing the scene in a single pass (after an initial<br />
earlier pass to generate the shadow map).<br />
If shaders are not available, performing the depth map test must usually be<br />
implemented by some hardware extension (such as GL_ARB_shadow [1] ),<br />
which usually do not allow a choice between two lighting models (lighted and<br />
shadowed), and necessitate more rendering passes:<br />
Final scene, rendered with ambient<br />
shadows.<br />
1. Render the entire scene in shadow. For the most common lighting models (see Phong reflection model) this<br />
should technically be done using only the ambient component of the light, but this is usually adjusted to also<br />
include a dim diffuse light to prevent curved surfaces from appearing flat in shadow.<br />
2. Enable the depth map test, and render the scene lit. Areas where the depth map test fails will not be overwritten,<br />
and remain shadowed.<br />
3. An additional pass may be used for each additional light, using additive blending to combine their effect with the<br />
lights already drawn. (Each of these passes requires an additional previous pass to generate the associated shadow<br />
map.)<br />
The example pictures in this article used the OpenGL extension GL_ARB_shadow_ambient [2] to accomplish the<br />
shadow map process in two passes.<br />
Shadow map real-time implementations<br />
One of the key disadvantages of real time shadow mapping is that the size and depth of the shadow map determines<br />
the quality of the final shadows. This is usually visible as aliasing or shadow continuity glitches. A simple way to<br />
overcome this limitation is to increase the shadow map size, but due to memory, computational or hardware<br />
constraints, it is not always possible. Commonly used techniques for real-time shadow mapping have been developed<br />
to circumvent this limitation. These include Cascaded Shadow Maps, [3] Trapezoidal Shadow Maps, [4] Light Space<br />
Perspective Shadow maps, [5] or Parallel-Split Shadow maps. [6]<br />
Also notable is that generated shadows, even if aliasing free, have hard edges, which is not always desirable. In order<br />
to emulate real world soft shadows, several solutions have been developed, either by doing several lookups on the<br />
shadow map, generating geometry meant to emulate the soft edge or creating non standard depth shadow maps.<br />
Notable examples of these are Percentage Closer Filtering, [7] Smoothies, [8] and Variance Shadow maps. [9]