Shadow Mapping

Shadow mapping is a method of computer graphics to represent shadows. The concept was presented in 1978 in the paper "casting curved shadows on curved surfaces" by Lance Williams. Shadow maps are used both for offline rendering as well as for real-time applications.

When Shadow Mapping Shadows are generated by testing whether a pixel is visible from a light source. The so-called shadow map is first generated. This is a depth map generated from the perspective of the light source. This contains information about the shortest distance of objects in a scene to the light source ( Z- buffer). By comparing the distance of the object to be rendered to the light source and the corresponding point in the shadow map of the shadow can be calculated.

Principle of operation

Rendering a scene with shadows with the aid of a shadow map essentially takes place in two steps. First, the scene is rendered from the perspective of light and stores the depth information for each visible object. Then, the scene is rendered normally, wherein it is determined for each pixel using the shadow map if it is visible to the light. If this is not the case, the pixel is rendered shaded.

This technique provides less accurate results than shadow volumes, but is generally faster in the calculation, also shadow maps can be realized without the assistance of Stencilbuffers and allow you to draw soft edges.

Algorithm

Draw the shadow map

First, the depth map for each light is created. For the point light sources to a perspective projection should be used, while for collimated light source with parallel radiation (such as for example the sun ) is an orthogonal projection is suitable. For this, the scene is rendered from the position of the light and stores the depth information. Often, the depth map is stored as a texture in memory of the graphics card. For this rendering process runs as efficiently as possible, both the light and the color calculation can be omitted or disconnected.

Every time you change the position of a light or an object in the scene, the depth maps need to be recalculated.

Shade of the scene

As a second step, the scene is rendered from the camera's view and the shadow map applied to each pixel. This step consists of three major operations. The first is to transform the relative coordinates of an object in comparison to the camera corresponding to the relative coordinates as seen from the light. Second, the coordinates of the depth map are compared and the Last, the object is drawn as illuminated or shaded.

Uniform shadow mapping

When drawing the actual scene may be compared to the distance for each pixel, the distance from the light source, which is for this point in the low texture. If the distance of the pixel is greater than the distance stored in the texture, the pixel is in the shadow.

For global light sources such as the sun is the area over which extends the depth texture, very large. The spatial resolution of the shadow is therefore very low. The uniform distribution of the texture space over the affected area also means that the perceived by the viewer shadow resolution is very low in the area, while in the distance unnecessarily high resolution is reached.

Perspective Shadow Mapping ( PSM)

Perspective Shadow Mapping extends the projection matrix of the light by a perspective projection, the viewer component. Thus, the previously square area in which the shadow texture is deformed to a trapezoid that has its narrow side to the viewer, and thus there is very much more texels per unit offers as in the distance. The method works well for scenarios in which the observer's viewing direction largely perpendicular to the light direction. However, the method has some numerical Feign Death, in which the projection matrix accepts invalid values ​​or inverts the shadows.

Light Space Perspective Shadow Mapping ( LiSPM )

Light Space Perspective Shadow Mapping ( used for example in SpellForce 2 ) is an extension of the PSM method, the designed freely selectable by changing formulas the degree of perspective distortion of the light projection. In a perpendicular angle to the light direction, this method of PSM method is equivalent. Depending parallel view direction and light direction, the lower the perspective distortion until the method falls back to normal parallelism uniform shadow mapping. This method prevents the Feign Death of PPPs. However, the optical result is still highly dependent on the viewing direction.

Cascaded Shadow Mapping ( CSM)

Cascaded Shadow Mapping ( used for example in 3DMark2005 and 3DMark2006 ) prevents the unequal distribution of shadow texel density by using multiple nested shadow maps for different distances. Every single shadow map is projected uniform or can be projected in perspective with one of the above variants. The method is easy to implement and provides flexible adjustment of shadow quality for all distances, but requires a multiple of the CPU time and the graphics card memory other methods.

Dual paraboloid shadow mapping ( DPSM )

The traditional technique of shadow mapping using only one depth map. But if you want a shining light in multiple directions, for example, realize a point light, the traditional method is no longer sufficient. So you came over time to dual paraboloid shadow mapping, a technique in which one projects the space around the light source on two paraboloids, which correspond to two low cards. This method is nearly as efficient as the traditional shadow mapping, but also has drawbacks, which mainly related to the distortion caused by the projection onto the convex paraboloid. By appropriate countermeasures can these but reduced to a minimum.

Dual paraboloid mapping was first described in 1998 in the publication " View -independent environment maps" by Wolfgang Heidrich and Hans -Peter Seidel.

Other methods

There are other ways, shadow maps represent improved, but they are not suitable for calculating in real time. They work by segmenting the scene and assignment of different sized shadow texture fragments to these segments according to various quality criteria. There are also real-time variations, but the layout of the scene in real-time is difficult and leads to cracks in the visible quality of the shadow in the picture.

725772
de