07.01.2013 Views

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

3D graphics eBook - Course Materials Repository

SHOW MORE
SHOW LESS

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 183<br />

External links<br />

• Hardware Shadow Mapping (http:/ / developer. nvidia. com/ attach/ 8456), nVidia<br />

• Shadow Mapping with Today's OpenGL Hardware (http:/ / developer. nvidia. com/ attach/ 6769), nVidia<br />

• Riemer's step-by-step tutorial implementing Shadow Mapping with HLSL and DirectX (http:/ / www. riemers.<br />

net/ Tutorials/ DirectX/ Csharp3/ index. php)<br />

• NVIDIA Real-time Shadow Algorithms and Techniques (http:/ / developer. nvidia. com/ object/ doc_shadows.<br />

html)<br />

• Shadow Mapping implementation using Java and OpenGL (http:/ / www. embege. com/ shadowmapping)<br />

Shadow volume<br />

Shadow volume is a technique used in <strong>3D</strong> computer <strong>graphics</strong> to add<br />

shadows to a rendered scene. They were first proposed by Frank Crow<br />

in 1977 [1] as the geometry describing the <strong>3D</strong> shape of the region<br />

occluded from a light source. A shadow volume divides the virtual<br />

world in two: areas that are in shadow and areas that are not.<br />

The stencil buffer implementation of shadow volumes is generally<br />

considered among the most practical general purpose real-time<br />

shadowing techniques for use on modern <strong>3D</strong> <strong>graphics</strong> hardware. It has<br />

been popularised by the video game Doom 3, and a particular variation<br />

of the technique used in this game has become known as Carmack's<br />

Reverse (see depth fail below).<br />

Example of Carmack's stencil shadowing in<br />

Doom 3.<br />

Shadow volumes have become a popular tool for real-time shadowing, alongside the more venerable shadow<br />

mapping. The main advantage of shadow volumes is that they are accurate to the pixel (though many<br />

implementations have a minor self-shadowing problem along the silhouette edge, see construction below), whereas<br />

the accuracy of a shadow map depends on the texture memory allotted to it as well as the angle at which the shadows<br />

are cast (at some angles, the accuracy of a shadow map unavoidably suffers). However, the shadow volume<br />

technique requires the creation of shadow geometry, which can be CPU intensive (depending on the<br />

implementation). The advantage of shadow mapping is that it is often faster, because shadow volume polygons are<br />

often very large in terms of screen space and require a lot of fill time (especially for convex objects), whereas<br />

shadow maps do not have this limitation.<br />

Construction<br />

In order to construct a shadow volume, project a ray from the light source through each vertex in the shadow casting<br />

object to some point (generally at infinity). These projections will together form a volume; any point inside that<br />

volume is in shadow, everything outside is lit by the light.<br />

For a polygonal model, the volume is usually formed by classifying each face in the model as either facing toward<br />

the light source or facing away from the light source. The set of all edges that connect a toward-face to an away-face<br />

form the silhouette with respect to the light source. The edges forming the silhouette are extruded away from the<br />

light to construct the faces of the shadow volume. This volume must extend over the range of the entire visible<br />

scene; often the dimensions of the shadow volume are extended to infinity to accomplish this (see optimization<br />

below.) To form a closed volume, the front and back end of this extrusion must be covered. These coverings are<br />

called "caps". Depending on the method used for the shadow volume, the front end may be covered by the object<br />

itself, and the rear end may sometimes be omitted (see depth pass below).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!