Real-Time Rendering——7.7 Filtered Shadow Maps过滤阴影贴图

One algorithm that allows filtering of the shadow maps generated is Donnelly and Lauritzen’s variance shadow map (VSM) [368]. The algorithm stores the depth in one map and the depth squared in another map. MSAA or other antialiasing schemes can be used when generating the maps. These maps can be blurred, mipmapped, put in summed area tables [988], or any other method. The ability to treat these maps as filterable textures is a huge advantage, as the entire array of sampling and filtering techniques can be brought to bear when retrieving data from them.

 

一种允许过滤生成的阴影图的算法是唐纳利和劳里岑的方差阴影图(VSM) [368]。该算法在一个图中存储深度,在另一个图中存储深度的平方。生成地图时,可以使用MSAA或其他抗锯齿方案。这些图可以被模糊、小中见大贴图、放入总面积表[988]或任何其他方法。将这些贴图视为可过滤纹理的能力是一个巨大的优势,因为从这些贴图中检索数据时,可以使用整个采样和过滤技术阵列。

We will describe VSM in some depth here, to give a sense of how this process works; also, the same type of testing is used for all methods in this class of algorithm.Readers interested in learning more about this area should access the relevant references, and we also recommend the book by Eisemann et al. [412], which gives the topic considerably more space.

我们将在这里比较深入地描述VSM,让大家了解这个过程是如何运作的;同样,这类算法中的所有方法都使用相同类型的测试。有兴趣了解该领域更多信息的读者应该访问相关参考资料,我们也推荐Eisemann等人的书【412】,这本书给了这个主题相当大的空间。

To begin, for VSM the depth map is sampled (just once) at the receiver’s location to return an average depth of the closest light occluder. When this average depth M1, called the first moment, is greater than the depth on the shadow receiver t, the receiver is considered fully in light. When the average depth is less than the receiver’s depth, the following equation is used:

先,对于VSM,深度图在接收器的位置被采样(仅一次),以返回最近的光遮挡器的平均深度。当这个被称为第一矩的平均深度M1大于阴影接收器上的深度t时,该接收器被认为完全处于光线中。当平均深度小于接收器的深度时,使用以下等式:

where pmax is the maximum percentage of samples in light, σ2 is the variance, t is the receiver depth, and M1 is the average expected depth in the shadow map. The depthsquared shadow map’s sample M2, called the second moment, is used to compute the variance:

其中,pmax是光照中样本的最大百分比,σ2是方差,t是接收器深度,M1是阴影贴图中的平均预期深度。深度平方阴影贴图的样本M2称为二阶矩,用于计算方差:


 

The value pmax is an upper bound on the visibility percentage of the receiver. The actual illumination percentage p cannot be larger than this value. This upper bound is from the one-sided variant of Chebyshev’s inequality. The equation attempts to estimate, using probability theory, how much of the distribution of occluders at the surface location is beyond the surface’s distance from the light. Donnelly and Lauritzen show that for a planar occluder and planar receiver at fixed depths, p = pmax, so Equation 7.7 can be used as a good approximation of many real shadowing situations.

pmax值是接收者可见性百分比的上限。实际照明百分比p不能大于该值。这个上界来自于切比雪夫不等式的单侧变型。该方程试图使用概率理论来估计在表面位置有多少遮光器的分布超出了表面与光的距离。Donnelly和Lauritzen表明,对于固定深度的平面遮光器和平面接收器,p = pmax,因此等式7.7可以用作许多真实阴影情况的良好近似。

Myers [1251] builds up an intuition as to why this method works. The variance over an area increases at shadow edges. The greater the difference in depths, the greater the variance. The (t - M1)2 term is then a significant determinant in the visibility percentage. If this value is just slightly above zero, this means the average occluder depth is slightly closer to the light than the receiver, and pmax is then near 1 (fully lit). This would happen along the fully lit edge of the penumbra. Moving into the penumbra, the average occluder depth gets closer to the light, so this term becomes larger and pmax drops. At the same time the variance itself is changing within the penumbra, going from nearly zero along the edges to the largest variance where the occluders differ in depth and equally share the area. These terms balance out to give a linearly varying shadow across the penumbra. See Figure 7.26 for a comparison with other algorithms.

Myers [1251]对这种方法为什么有效建立了一种直觉。阴影边缘区域的变化增加。深度差异越大,差异越大。(t - M1)平方 项是可见度百分比的一个重要决定因素。如果该值略高于零,这意味着平均遮光器深度比接收器稍微更靠近光线,pmax则接近1(完全照亮)。这将发生在半影的完全照亮的边缘。移动到半影中,平均遮光器深度变得更靠近光,因此这一项变得更大,pmax下降。同时,方差本身在半影内变化,从沿边缘的接近零变化到遮光器深度不同且面积相等的最大方差。这些项相互抵消,在半影上形成线性变化的阴影。与其他算法的比较见图7.26。

 

Figure 7.26. In the upper left, standard shadow mapping. Upper right, perspective shadow mapping, increasing the density of shadow-map texel density near the viewer. Lower left, percentage closer soft shadows, softening the shadows as the occluder’s distance from the receiver increases. Lower right, variance shadow mapping with a constant soft shadow width, each pixel shaded with a single variance map sample. (Images courtesy of Nico Hempe, Yvonne Jung, and Johannes Behr.)

图7.26。在左上角,标准阴影贴图。右上角,透视阴影贴图,增加观察者附近阴影贴图纹理的密度。左下,百分比更近的软阴影,随着遮光器与接收器的距离增加而使阴影变软。右下,具有恒定软阴影宽度的方差阴影贴图,每个像素都用单个方差贴图样本着色。(图片由Nico Hempe、Yvonne Jung和Johannes Behr提供。)

One significant feature of variance shadow mapping is that it can deal with the problem of surface bias problems due to geometry in an elegant fashion. Lauritzen [988] gives a derivation of how the surface’s slope is used to modify the value of the second moment. Bias and other problems from numerical stability can be a problem for variance mapping. For example, Equation 7.8 subtracts one large value from another similar value. This type of computation tends to magnify the lack of accuracy of the underlying numerical representation. Using floating point textures helps avoid this problem.

方差阴影贴图的一个重要特征是,它可以以优雅的方式处理由于几何体而产生的曲面偏差问题。Lauritzen [988]给出了如何使用表面斜率来修改二阶矩值的推导。数值稳定性带来的偏差和其他问题可能是方差映射的一个问题。例如,等式7.8从另一个相似的值中减去一个大值。这种类型的计算往往会放大潜在数值表示的不准确性。使用浮点纹理有助于避免这个问题。

Overall VSM gives a noticeable increase in quality for the amount of time spent processing, since the GPU’s optimized texture capabilities are used efficiently. While PCF needs more samples, and hence more time, to avoid noise when generating softer shadows, VSM can work with just a single, high-quality sample to determine the entire area’s effect and produce a smooth penumbra. This ability means that shadows can be made arbitrarily soft at no additional cost, within the limitations of the algorithm.

由于GPU的优化纹理功能得到了有效利用,整体VSM在处理时间的质量方面有了显著提高。虽然PCF需要更多的样本,因此需要更多的时间来避免生成更柔和的阴影时的噪声,但VSM可以只用一个高质量的样本来确定整个区域的效果,并产生一个平滑的半影。这种能力意味着,在算法的限制范围内,阴影可以被任意柔化,而不需要额外的成本。

As with PCF, the width of the filtering kernel determines the width of the penumbra. By finding the distance between the receiver and the closest occluder, the kernel width can be varied, so giving convincing soft shadows. Mipmapped samples are poor estimators of coverage for a penumbra with a slowly increasing width, creating boxy artifacts. Lauritzen [988] details how to use summed-area tables to give considerably better shadows. An example is shown in Figure 7.27.

与PCF一样,过滤内核的宽度决定了半影的宽度。通过寻找接收器和最近的遮光器之间的距离,可以改变内核宽度,从而给出令人信服的软阴影。对于宽度缓慢增加的半影,小中见大贴图样本是覆盖范围的不良估计值,从而产生盒状伪像。Lauritzen [988]详细介绍了如何使用总面积表来给出更好的阴影。图7.27给出了一个例子。

Figure 7.27. Variance shadow mapping, where the distance to the light source increases from left to right. (Images from the NVIDIA SDK 10 [1300] samples, courtesy of NVIDIA Corporation.)

方差阴影贴图,到光源的距离从左到右增加。(图片来自NVIDIA SDK 10 [1300]样本,由NVIDIA Corporation提供。)

One place variance shadow mapping breaks down is along the penumbrae areas when two or more occluders cover a receiver and one occluder is close to the receiver. The Chebyshev inequality from probability theory will produce a maximum light value that is not related to the correct light percentage. The closest occluder, by only partially hiding the light, throws off the equation’s approximation. This results in light bleeding (a.k.a. light leaks), where areas that are fully occluded still receive light. See Figure 7.28. By taking more samples over smaller areas, this problem can be resolved, turning variance shadow mapping into a form of PCF. As with PCF, speed and performance trade off, but for scenes with low shadow depth complexity, variance mapping works well. Lauritzen [988] gives one artist-controlled method to ameliorate the problem, which is to treat low percentages as fully shadowed and to remap the rest of the percentage range to 0% to 100%. This approach darkens light bleeds, at the cost of narrowing penumbrae overall. While light bleeding is a serious limitation,VSM is good for producing shadows from terrain, since such shadows rarely involve multiple occluders [1227].

当两个或更多遮光器覆盖接收器并且一个遮光器靠近接收器时,方差阴影映射的一个地方是沿着半影区域。概率论中的切比雪夫不等式将产生一个与正确的光百分比无关的最大光值。最接近的遮光器,只隐藏了部分光线,就推翻了方程式的近似值。这导致了漏光(也称为漏光),完全被遮挡的区域仍然可以接收到光线。参见图7.28。通过在更小的区域内采集更多的样本,这个问题可以得到解决,将方差阴影贴图转化为一种PCF形式。与PCF一样,速度和性能会有所取舍,但对于阴影深度复杂度较低的场景,方差贴图效果很好。Lauritzen [988]给出了一种由艺术家控制的方法来改善该问题,该方法将低百分比视为完全阴影,并将其余百分比范围重新映射到0%到100%。这种方法以缩小整个半影为代价,使光渗现象变暗。虽然光渗现象是一个严重的限制,VSM是很好的从地形产生阴影,因为这样的阴影很少涉及多个遮挡物[1227]。

Figure 7.28. On the left, variance shadow mapping applied to a teapot. On the right, a triangle (not shown) casts a shadow on the teapot, causing objectionable artifacts in the shadow on the ground.(Images courtesy of Marco Salvi.) 

图7.28。在左侧,方差阴影贴图应用于茶壶。在右边,一个三角形(未示出)在茶壶上投射了一个阴影,在地面上的阴影中产生了令人讨厌的伪像。(图片由马可·萨尔维提供。)

The promise of being able to use filtering techniques to rapidly produce smooth shadows generated much interest in filtered shadow mapping; the main challenge is solving the various bleeding problems. Annen et al. [55] introduced the convolution shadow map. Extending the idea behind Soler and Sillion’s algorithm for planar receivers [1673], the idea is to encode the shadow depth in a Fourier expansion. As with variance shadow mapping, such maps can be filtered. The method converges to the correct answer, so the light leak problem is lessened.

能够使用过滤技术快速产生平滑阴影的前景引起了人们对过滤阴影贴图的极大兴趣;主要的挑战是解决各种光渗现象。Annen等人[55]介绍了卷积阴影图。扩展Soler和Sillion的平面接收器算法[1673]背后的思想,该思想是在傅立叶展开中编码阴影深度。与方差阴影贴图一样,可以过滤此类贴图。该方法收敛到正确的答案,因此减少了漏光问题。

A drawback of convolution shadow mapping is that several terms need to be computed and accessed, considerably increasing both execution and storage costs [56, 117]. Salvi [1529, 1530] and Annen et al. [56] concurrently and independently came upon the idea of using a single term based on an exponential function. Called an exponential shadow map (ESM) or exponential variance shadow map (EVSM), this method saves the exponential of the depth along with its second moment into two buffers.An exponential function more closely approximates the step function that a shadow map performs (i.e., in light or not), so this works to significantly reduce bleeding artifacts. It avoids another problem that convolution shadow mapping has, called ringing, where minor light leaks can happen at particular depths just past the original occluder’s depth.

卷积阴影映射的一个缺点是需要计算和访问几个项,这大大增加了执行和存储成本[56,117]。萨尔维[1529,1530]和Annen等人[56]同时且独立地想到了使用基于指数函数的单个项的想法。这种方法被称为指数阴影贴图(ESM)或指数方差阴影贴图(EVSM),它将深度的指数及其二阶矩保存到两个缓冲区中。指数函数更接近于阴影贴图执行的阶跃函数(即,有光或无光),因此这有助于显著减少漏光。它避免了卷积阴影贴图具有的另一个问题,称为振铃,其中微小的光泄漏可能发生在刚刚超过原始遮光器深度的特定深度。

A limitation with storing exponential values is that the second moment values can become extremely large and so run out of range using floating point numbers. To improve precision, and to allow the exponential function to drop off more steeply,z-depths can be generated so that they are linear [117, 258].

存储指数值的一个限制是二阶矩值可能变得非常大,因此超出了使用浮点数的范围。为了提高精度,并允许指数函数更陡峭地下降,可以生成z深度,以便它们是线性的[117,258]。

Due to its improved quality over VSM, and its lower storage and better performance compared to convolution maps, the exponential shadow map approach has sparked the most interest of the three filtered approaches. Pettineo [1405] notes several other improvements, such as the ability to use MSAA to improve results and to obtain some limited transparency, and describes how filtering performance can be improved with compute shaders.

由于其质量优于VSM,并且与卷积映射相比具有更低的存储量和更好的性能,指数阴影映射方法在三种滤波方法中引起了最大的兴趣。pettino[1405]提到了其他几项改进,例如使用MSAA来改进结果和获得一些有限透明度的能力,并描述了如何通过计算着色器来提高过滤性能。

More recently, moment shadow mapping was introduced by Peters and Klein [1398].It offers better quality, though at the expense of using four or more moments, increasing storage costs. This cost can be decreased by the use of 16-bit integers to store the moments. Pettineo [1404] implements and compares this new approach with ESM,providing a code base that explores many variants.

最近,Peters和Klein [1398]引入了矩影映射。它提供了更好的质量,尽管以使用四个或更多的矩为代价,增加了存储成本。通过使用16位整数来存储矩,可以降低这一成本。pettino[1404]实现了这种新方法,并将其与ESM进行了比较,提供了一个探索许多变体的代码库。

Cascaded shadow-map techniques can be applied to filtered maps to improve precision [989]. An advantage of cascaded ESM over standard cascaded maps is that a single bias factor can be set for all cascades [1405]. Chen and Tatarchuk [258] go into detail about various light leak problems and other artifacts encountered with cascaded ESM, and present a few solutions.

级联阴影贴图技术可应用于过滤后的贴图,以提高精确度[989]。与标准级联图相比,级联ESM的优势在于可以为所有级联设置单个偏差因子[1405]。陈和【258】详细介绍了级联ESM遇到的各种漏光问题和其他伪像,并提出了一些解决方案。

Filtered maps can be thought of as an inexpensive form of PCF, one that needs few samples. Like PCF, such shadows have a constant width. These filtered approaches can all be used in conjunction with PCSS to provide variable-width penumbrae [57,1620, 1943]. An extension of moment shadow mapping also includes the ability to provide light scattering and transparency effects [1399].

过滤地图可以被认为是PCF的一种廉价形式,只需要很少的样本。像PCF一样,这样的阴影具有恒定的宽度。这些过滤方法都可以与PCSS结合使用,以提供可变宽度的半影[57,1620,1943]。矩影贴图的扩展还包括提供光散射和透明效果的能力[1399]。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

椰子糖莫莫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值