Shadow Map技术最早由Lance Williams于1978在一篇题为"Casting Curved Shadow on Curved Surfaces"的论文中提出,其基本思想是(摘录):
反锯齿第一役,PCF(Percentage Closer Filtering),来自于Pixar的William T. Reeves, David H. Salesin 和 Robert L. Cook的一篇名为"Rendering Antialiased Shadows with Depth Maps"的论文。既然不能对Shadow Map做Filtering,那么就对比较结果做Filtering是PCF的精髓所在(摘录):
Our solution reverses the order of the filtering and comparison steps. The z values of the depth map across the entire region are first compared against the depth of the surface being rendered. This sample transformation converts the depth map under the region into a binary image, which is then filtered to give the proportion of the region in shadow. The resulting shadows have soft, antialiased edges.
值得一提的是,PCF可以产生soft shadow,虽然并不是真实的soft shadow,因为它与surface和光源的距离无关。
反锯齿第二役,Perspective Shadow Maps,来自于Marc Stamminger和George Drettakis。该方法的创新之处在于Shadow Map在normalized device coordinate空间生成,如此就:providing high resolution for near objects, and decreased resolution as we move away from the viewpoint.
反锯齿第三役,Variance Shadow Maps,来自于William Donnelly和Andrew Lauritzen。
- A view of the scene is constructed from the point of view of the light source. Only the Z values and not the shading values need be computed and stored.
- A view of the scene is then constructed from the point of view of the observer's eye. A linear transformation exists which maps X, Y, Z points in the observer's view into X, Y, Z coordinates in the light source view. As each point is generated in the observer's view, it is transformed into the computed view in the light source before computing its shading value. If the point is not visible to the light source, it is in shadow and is shaded accordingly.
反锯齿第一役,PCF(Percentage Closer Filtering),来自于Pixar的William T. Reeves, David H. Salesin 和 Robert L. Cook的一篇名为"Rendering Antialiased Shadows with Depth Maps"的论文。既然不能对Shadow Map做Filtering,那么就对比较结果做Filtering是PCF的精髓所在(摘录):
Our solution reverses the order of the filtering and comparison steps. The z values of the depth map across the entire region are first compared against the depth of the surface being rendered. This sample transformation converts the depth map under the region into a binary image, which is then filtered to give the proportion of the region in shadow. The resulting shadows have soft, antialiased edges.
值得一提的是,PCF可以产生soft shadow,虽然并不是真实的soft shadow,因为它与surface和光源的距离无关。
反锯齿第二役,Perspective Shadow Maps,来自于Marc Stamminger和George Drettakis。该方法的创新之处在于Shadow Map在normalized device coordinate空间生成,如此就:providing high resolution for near objects, and decreased resolution as we move away from the viewpoint.
反锯齿第三役,Variance Shadow Maps,来自于William Donnelly和Andrew Lauritzen。
VSM的实现相当简单,虽然它的原理涉及到一些统计学的东西,其思路是(摘录):
Instead of storing a single depth value, we store the mean and mean squared of a distribution of depths, from which we can efficiently compute the variance over any filter region. Using the variance, we derive an upper bound on the fraction of a shaded fragment that is occlueded. We show that this bound often provedes a good approximation to the true occlusion, and can be used as an approximate value for rendering.
另外文中提到的Mipmapping和Gaussian blur技术,是anti-aliasing和soften shadow很有效的手段,并且mipmapping对提高效率也有很大帮助。目前的shader可以很容易将上述技术与Variance Shadow Map很好的结合,产生更加逼真的shadow。
在Xbox360的XDK的samples中,有很好的Mipmapping和Variance Shadow Map的例子。
关于Shadow Map,还有很多相关技术;这里主要是针对游戏行业进行的选择。


