Some Problems in cascaded shadow map (CSM)

Source: Internet
Author: User

Cascaded shadow map (CSM) is currently the mainstream Shadow technology in the engine, and the efficiency and effect are both good. It is different from the traditional shadow map in that it splits the cone into layers, and each layer separately calculates the related SM, in this way, you can avoid the disadvantages of traditional SM by rendering the shadows of large scenes. The typical CSM principle is basically as follows:

Although it seems that the principle is simple, it is not easy to implement a robust CSM in practice. It involves various problems, some of which are inherent in this method, multiple methods are required to solve or circumvent the problem.

1. computation close Projection Matrix

To improve the effective utilization of Sm (that is, to minimize the area of irrelevant areas in the generated sm), we need to minimize the projection matrix used when generating SM, in this way, we need to calculate the tight projection matrix of the frustum corresponding to the current cascade. This generally calculates the AABB enclosure corresponding to the cone in the light source space:

However, direct use of AABB brings about another problem. Because the attributes of camera change in real time, the attributes of the corresponding frustum will also change, AABB is sensitive to changes in frustum, which may result in huge changes in AABB corresponding to frustum in the first and second frames, the valid resolution of the generated Sm (the number of pixels occupied by a fixed object after it is projected into SM, and the size of SM does not change) A sudden change may occur in two consecutive frames, so that the problem of shadow jitter may occur. I have a thesis on this question (stable
Cascaded shadow maps) proposed a solution to use sphere to replace AABB, because sphere is less sensitive to frustum changes, which will solve the jitter problem to a certain extent. A better solution is the progressive transformation of frustum mentioned in practical cascaded shadow maps in shader X7. It also solves the jitter problem caused by Rasterization to some extent.

2. Calculate the optimized distance crop plane

Because shadow map is sensitive to the accuracy of the Z value during use, it is necessary to increase the accuracy of the valid Z value as much as possible during SM generation, which leads to another problem: that is to use a relatively optimized distance plane when generating the SM. The primary principle here is to use a conservative method to obtain a relatively optimized near-far plane as much as possible. A too radical method can easily Overcut an object and cause a shadow vulnerability. The AABB corresponding to the cone of the light source cannot be used to calculate the distance plane. In this way, when the scene is too large, some objects within the near plane are missed. A more reasonable method is to use the expanded light cone at both ends to calculate a reasonable distance plane with the scenario.

3. Remove redundant objects between cascade

Generally, when using CSM, You need to divide the view frustum into several cascades. In most cases, the direction of the light source is not vertical to that of the view, in this way, the visual cones corresponding to light may overlap each other during rendering of each SM, which leads to repeated painting of the geometric element of the overlapping part, as shown in:

In this case, you can remove overlapping parts to reduce the number of ry elements to be drawn and increase the generation speed of SM. However, note that if you use the SM generation method with elimination, you need to use the map-based cascade selection method to select the most suitable SM during SM search, instead, you cannot use the split index-based method to directly locate the current pixel to Its Sm. Otherwise, the shadow vulnerability may occur. In addition, you also need to adjust the far plane of the light source cone at each level so that it can contain some objects in the next layer, otherwise, some pixel-level SM will appear.
But it does not generate an object that actually contains the cone at the next level, which will also miss some shadows.

The two articles about CSM combined with the examples in d3d SDK are good: cascaded shadow maps, common
Techniques to imporve shadow depth maps; in addition, there are stable cascade shadow map in shader X6 and practical cascade shadow map in X7. The last article summarizes the Optimization Problems of CSM in multiple aspects (such as the shadow map pack), which is quite good.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.