Shadow Map
Shadow Map | shadow mapOne of the methods of construction of shadows, namely, the use of Z-buffer to determine the pixel, whether the target point in the shadows. The method of shadow maps based on the idea that the lit terms are those terms that "visible" light source. "Appearance" in this case means that this point has successfully passes the test depth when rendering from the source of light - that is, they are not superseded by other objects. Therefore, all the points that are "invisible" from the position of the light source, are in the shade.
The method works in two passes: first is the rendering of the source of light - the depth values are recorded in a special buffer. And then done the normal rendering, during which the buffer is used to check if a pixel in the shade (this test is carried out in the ����������� �������).
Usually the shadow cards are used with light source (such as the sun), to render the depth buffer is used orthogonal projection. However, the method is compatible with point light sources - for this instead of a depth buffer rendering is cubic maps (6 depth buffers on the sides of the Cuba, ambient light source) from the perspective projection. When a large number of light sources, this technique greatly increases the load on the GPU, so in practice the shadow ���������� usually only for a few of the most important sources of light, depending on the nature of the ������������ scene.
Shadow maps are very effective - they are much faster than the shadow volume. But they have and the lack of - a strong aliasing: In other words, if you do not use a giant depth buffer, the shadows are much �����������������. This artifact is usually eliminate the filtering (blurring) of a sample of the depth buffer core 3x3 or 5x5 - as a result of which are soft shadows without The ������������. This extension method of the shadow maps has received the name of the PCF (Percentage Closer Filtering).
The classic shadow cards have a limited area coverage. That is, it is impossible to make all visible objects in the scene ����������� qualitative shadow - increasing the size of the projection of the reduced detail and, consequently, increased aliasing. When decreasing, respectively, the remote objects fall out of the field of view" of the light source and do not cast shadows of the most popular technique that solves this problem - cascading shadow maps (Cascaded Shadow Maps, CSM). It is the rendering of several shadow buffers instead of one, with different sizes of projections - they are called shadow cascades. Typically used 3-4 cascade. Then The ����������� ������� desired buffer is selected depending on the coordinates of the current pixel - usually a sample ������������� between neighboring cascades to get smooth transitions. As a result of the shadow map covers almost all the visible scene: are qualitative shadows in the vicinity of the camera and ����������������� - away. ������������ distant shadows practically not noticeable to the audience - he sees only that distant objects also cast shadows, and this is enough.
The main difficulty of the CSM method is the effective location of the cascades on the pyramid of visibility. The most simple solution - align with the center at the position of the camera, but in this case, the effective area of the cascades will be only about a third of their real size, since each time the viewer sees not the entire cascade, the only part of it, the corresponding horizontal angle of view camera. In modern implementations of CSM position and size of the projections of the cascades is usually picked up so that they completely fell inside the pyramid of visibility and covered it as soon as more tightly.
There is also a popular method of expansion of shadow maps - Variance Shadow Map (VSM). It depth buffer stores two values for each pixel - actually the depth and its square, this uses the buffer values with a floating point. To obtain a sample of the used buffer Chebyshev inequality. The advantage is that of the VSM-buffer can be pre-filter once, and then use for further without rendering the PCF, greatly increasing the productivity. However, the VSM brings its artifacts, the most serious of which is the so-called light-bleeding, when in the zone of shadows appear bright spots. There are several ways to fix the problem, but they either require more memory, or make the shadows not as soft as we would like.
See also the Shadow Volume, the Z-Buffer.