Layers Variance Shadow Map

来源:互联网 发布:linux mount网络共享 编辑:程序博客网 时间:2024/05/21 10:52

我尝试翻译此篇文章,此文章是Andrew Laurizen和Michael McCool的大作。事先声明,本人的翻译水平有限,此翻译为参考。

首先对题目翻译一下:多层方差阴影图 。

ABSTRACT
Shadow maps are commonly used in real-time rendering, but they
cannot be filtered linearly like standard color, resulting in severe
aliasing. Variance shadow maps resolve this problem by representing
the depth distribution using moments, which can be linearly filtered.
However, variance shadow maps suffer from “light bleeding”
artifacts and require high-precision texture filtering hardware.
We introduce layered variance shadow maps, which provide simultaneous
solutions to both of these limitations. By partitioning
the shadow map depth range into multiple layers, we eliminate
all light bleeding between different layers. Using more layers increases
the quality of the shadows at the expense of additional storage.
Because each of these layers covers a reduced depth range,
they can be stored in lower precision than would be required with
typical variance shadow maps, enabling their use on a much wider
range of graphics hardware. We also describe an iterative optimization
algorithm to automatically position layers so as to maximize
the utility of each.
Our algorithm is easy to implement on current graphics hardware
and provides an efficient, scalable solution to the problem of
shadow map filtering.
Index Terms: I.3.7 [Computer Graphics]: Three-Dimensional
Graphics and Realism—Color, shading, shadowing, and texture

 

摘要:阴影图普遍用于实时渲染中,但此图不能标准纹理那样进行线形过滤,从而产生锯齿现象(之所以不能用线形过滤,是因为阴影图存储的是深度信息,而阴影的产生是深度比较的结果)。方差阴影图解决了这个问题,通过运用深度的分布情况(深度和深度平方的期望和方差),而这样深度信息就可以进行线形过滤(之所以能用线形过滤,是因为最后阴影的产生是通过深度信息求出来的,通过切尔雪夫不等式)。但是,方差阴影图算法会引起"light bleeding"假象(之所以会出现light bleeding,是因为深度信息不够充足),需要更高分辨率的渲染纹理(render target),(比如两个R32F的渲染纹理),但是对于此高分辨率的渲染纹理,硬件不支持此类纹理的过滤。所以作者引入了多层方差阴影图算法,从而解决此类问题。此算法是将shadow map(阴影图)的深度信息(深度范围)分多个层,从而在不同层间消除了"light bleeding" ,但在提高了阴影质量的同时,也增加了存储空间。每个层表示的深度范围缩小了,这样表示的精度也就缩小了,而这些缩小后的精度,绝大多数阴影都支持。同时作者通过递归的方法求出最佳的分层(通过K聚类的方法),从而让每层得到最佳的深度范围。

作者的算法在目前的图形显卡上能够很容易的实现,并且提供了一个针对阴影图过滤有效的,伸缩性好的方法。

索引词语:三维图形和现实---颜色,着色,阴影和纹理。

 

1 INTRODUCTION
Shadow maps [12] are the most commonly used shadowing technique
in real-time applications, providing several advantages over
shadow volumes [3]. Most notably, shadow maps can be queried at
arbitrary locations, they work with anything that can be rasterized
including alpha tested geometry, and they are much less sensitive
to geometric complexity than shadow volumes. Like most textures,
however, they suffer from aliasing if not properly filtered. Unfortunately,
common linear filtering algorithms such as mipmapping
and anisotropic filtering are inapplicable to ordinary shadow maps,
which require a non-linear depth comparison per sample.

1.引言

阴影图(shadow map)是目前在实时场景中普遍运用的生成阴影技术,相对于体积阴影(volume shadow)而言提供了许多优势。最引人注目的是:shadow map能够在任意的位置得到,并且能和任何几何体一起被珊格化,包括那些需要alpha test的几何体,并且shadow map对几何体的复杂度要求不高(相对于shadow volumes)。但是,像大多数纹理一样,如果过滤不恰当,shadow map也会出现锯齿(注意这里好像矛盾,其实不矛盾,此话是针对本文的算法)。比较糟糕的是:普通的线形过滤,如mipmapping和各向异性过滤对普通的shadow map不起作用,shadow map需要对每一个采样进行非线性的深度比较。

 

Variance shadow maps (VSMs) [4, 7] provide a solution to this
problem by representing a probability distribution of depths at each
shadow map texel. To achieve constant space usage, the distributions
are approximated using their first two moments. The visibility
function over an arbitrary filter region can be estimated using
Chebyshev’s Inequality, which yields an upper bound on the
amount of light reaching the fragment being shaded. In the case of
a single planar occluder and a single planar receiver the reconstruction
is exact [4], motivating its direct application to shading.

方差阴影图算法针对此问题提供了一个方法:通过在shadow map上的每一个纹素上作一个可能的深度分布表示。为了达到恒定距离的运用(此处翻译不好,本人还得斟酌),分布的估计运用到了两个时刻(这里moments的翻译也觉得不好):期望和方差。在一个任意的过滤区域的可见性函数可以通过切尔雪夫不等式来估计,此不等式产生一个所有光照达到此着色像素(fragment)总和的最高限。在一个单独的遮挡平面和一个单独的吸收光照平面的情况下进行阴影重建,得到的结果非常准确,证明此方法可行,从而激励此方法运用到了实时阴影生成的程序中。

 

However, because only two moments are stored, complex visibility
functions cannot be reconstructed perfectly. This leads to
regions that should be in shadow being lit, an artifact known as
“light bleeding”. Storing more moments could eliminate the problem,
but estimating the visibility function becomes very computationally
intensive as more moments are used. Furthermore higherorder
moments are numerically unstable, making them difficult to
use in practice. Even the second moment requires fairly high precision
storage and filtering to avoid numeric problems with large light
ranges. Graphics hardware that supports 32-bit floating point filtering is sufficent, but hardware with less precision (16-bit for example)
often is not. This limits the applicability of VSMs to high-end
hardware.

但是,因为仅仅两个时刻被存储,复杂的可见性函数不能被很好的重建。这样导致了"light bleeding"假象:那些需要在阴影区的地方被照亮。存储更多的时刻(E(x^3),E(x^4),E(x^5)等等)也许会解决此问题,但是通过它们产生的可见性函数计算量非常大,特别是更多的时刻被运用。再者,高次的时刻(前面提到的)是数值不稳定的,将它们运用到实践比较困难。即使是二次方差需要很高的精度存储纹理和运用大范围的灯光范围过滤去避免数值不稳定问题。显卡支持32位浮点纹理的是可以的,但是不支持的这样精度(16位)的显卡就不能用了。这样就限制了VSM算法的适用。

 

Rather than using more moments to improve the quality of
VSMs, we can instead alter the depth metric. The key observation
is that the visibility test is a function of the depth ordering in the
scene, not the specific depth values. We can thus choose any monotonic
warp of the depth metric and still obtain an upper bound on
the visibility using Chebyshev’s Inequality as with standard VSMs.

我们可以替换深度矩阵(存储深度的纹理),而不用更高次的时刻(方差之类)去提高VSM算法生成阴影的质量。问题的关键转化到了,可见测试是一个场景中深度的次序的函数,而不是具体的深度值。我们可以选择一个单调的深度扭曲矩阵,但还是能够得到运用切尔雪夫不等式得到可见度的最高限。

 

Moreover we can use any number of uniquely chosen warps.
Each warp will produce a different upper bound on the visibility
function, some tighter than others. We use this fact to partition the
light’s depth range into different layers, each of which has a unique
warping function. We choose these warps so that for a given depth
d, we know in advance which layer will provide the best approximation.
With this approach, only a single texture sample from one
layer is required for each fragment while shading, allowing us to
scale to a large number of layers.

再者,我们能够运用任何唯一选择的扭曲数值。每一个扭曲将产生一个通过可见性函数产生的不同的最高限,有些和其他的比较接近。我们运用这些扭曲将光源的深度范围划分为多层,每层有一个唯一的扭曲函数。我们选择了这些扭曲函数后,对一个给定的深度,我们就事先知道那一层将提供最好的估计。运用这种办法,当对一层中的每个象素进行着色处理时,仅仅对一个单独的纹理采样。这种方法允许我们对层数进行扩展。

 

A remaining problem is where to place the layer boundaries to
eliminate the most light bleeding. While uniformly or manually
placed layer boundaries may be sufficient for many applications, it
is desirable to have an automated method available. We describe an
iterative image-space optimization algorithm based on Lloyd relaxation
[5] in Section 4.

那么就要对如何分层进行探讨了,当平均分层或者手动分层也许对许多应用程序已经足够。但是运用自动分层效果更好。我们描述了一个基于Lloyd relaxation的在图像空间递归优化算法。

 

In summary, layered variance shadow maps (LVSMs) generalize
variance shadow maps and provide a scalable way to increase
shadow quality beyond what is possible with standard VSMs. Additionally,
LVSMs can be used with a wider range of graphics hardware
than VSMs since they do not require high-precision texture
filtering.

总之,多层方差阴影图算法继承了方差阴影图算法,并提供一个可扩展的方法去提高阴影的质量,而不是运用提高精度的标准的VSM算法。再者,由于LVSM不需要高精度的纹理过滤,所以可运行的显卡范围广泛。

 

2 RELATED WORK
Shadow maps [12] are an efficient method of computing shadows
in general scenes. Unfortunately, they suffer from several forms of
aliasing. There are two orthogonal bodies of research that address
these aliasing problems: projection optimization and shadow map
filtering. Lloyd [8] gives an excellent survey and analysis of various
warping an partitioning algorithms that aim to improve the shadow
projection. We address the filtering problem, but projection optimization
algorithms can be used in conjunction with our approach
to obtain high quality shadows.

2 相关工作

阴影图算法在一些普通场景中是一个有效计算阴影的算法。糟糕的是:它们会产生锯齿现象。在解决锯齿问题方面有两个研究流派:投影优化和阴影图过滤。Lloyd给出了许多很好的关于扭曲分层的提高阴影投影算法的介绍(哦?我得好好研究一下)。我们现在运用过滤的方法,不过也结合了投影优化的方法而得到高质量的阴影。

 

Percentage-closer filtering (PCF) [10] provides a way to filter
shadow maps by observing that the results of many depth comparisons
over a filter region should be averaged, rather than the depth
values themselves. This method does not support pre-filtering,
however, and so for large filter sizes it is very expensive. Additionally,
PCF does not consider the receiver geometry within the
filter region, which causes significant biasing problems.

PCF算法提供了一种方法:通过在过滤区域对深度比较结果进行平均,来过滤阴影图(不是过滤shadow map,是过滤深度比较结果)。这种方法不提供预过滤,但是,大的过滤区域将会计算时间比较长。再者,PCF不考虑接受几何体的过滤区域,这些造成了严重的偏移问题(哦。。。)。

 

Deep shadow maps [9] store a distribution of depths for each
shadow map texel and allow pre-filtering. Unfortunately general
deep shadow maps require a variable amount of storage per pixel,
making them unsuitable for implementation on current graphics
hardware. Furthermore averaging two distributions is non-trivial,
which complicates filtering.

Deep shadow maps算法在每一个Shadow map的纹素中存储了深度的分布并且可以预过滤。糟糕的是普通的deep shadow maps需要在每个象素有大容量存储(本人没有这方面经验,还需研究),这样对当前普通显卡来说不适用。再者,对两个分布平均操作也不是很简单,这样会过滤复杂。

 

Opacity shadow maps [6] and convolution shadow maps [1] represent
the visibility function with respect to a basis to allow linear
filtering. These algorithms are limited in their ability to represent
discontinuities in the visibility function, and thus suffer from
light bleeding near all occluders. Properly rendering any reasonably
sized scene requires a huge number of layers (in the case of opacity
shadow maps) or coefficients (in the case of convolution shadow
maps), which makes these solutions impractical for real-time rendering
of complex scenes. Furthermore, convolution shadow maps
need to sample all of the basis coefficients for a given shadow map
texel, which scales poorly as the number of coefficients increases.In contrast, layered variance shadow maps require only a single texture
sample per shaded pixel, just like variance shadow maps.

不透明阴影图算法和卷积阴影图算法展示了运用基函数重构阴影图(不准确)来进行线形过滤的可见度函数。这些算法受限于可见度函数的边界处理,并且在所有遮挡物的附近都有light bleeding假象(我得再把以前看的论文看看)。恰当的渲染任何合理大小的场景需要一大堆数目的层(在不透明阴影图算法情况下)或者系数(在卷积阴影图情况下),而这两者让这些方法在实时渲染复杂场景中不可行。再者,卷积阴影图算法需要采样给定阴影图纹素的所有基系数,当系数的数目增多时,伸展性很差。相比较而言,多层方差阴影图对于每个着色像素只需要单个纹理采样,就像方差阴影图算法。

 

Our algorithm also uses a piecewise representation of the visibility
function, but depth tests within each piece are resolved in
the same way as with standard variance shadow maps (VSMs)
[4]. Thus like VSMs our algorithm has no problem reconstructing
the visibility function in the case of a single planar occluder
and receiver. Unlike VSMs, however, we avoid multi-occluder
light bleeding artifacts by partitioning the depth range into multiple
pieces.

我们的算法也运用了一个分段表示的可见度函数,但是每段的深度比较和标准的方差阴影图算法一样进行的。那么像VSM算法那样,我们的算法在可以在只有一个遮挡平面和一个吸收平面情况下重构可见度函数。但是并不像VSM算法那样,我们通过划分深度范围,将其分段,避免了多遮挡物“light bleeding”假象。

 

3 ALGORITHM OVERVIEW
The algorithm is built on top of variance shadow maps [4, 7], which
we will review briefly here.

3 算法综述

此算法是建立在方差阴影图算法基础上,我们将简单回顾一下:

 

We begin by rendering both depth and squared depth into a twocomponent
variance shadow map. The VSM is sampled while shading
a fragment to produce the moments M1 and M2 of the depth
distribution F(x) over the texture filter region, defined as:
我们将深度和深度的平方渲染到一个两通道的方差阴影图上。当着色像素通过纹理过滤区域来产生深度分布F(x)时刻:M1和M2时将采样方差阴影图,定义如下:

(怎么回事,公式搞不上去)

 

From these we compute the mean and variance of the distribution:

从这些我们可以计算出的期望和方差分布:

(公式还是搞不上去)

 

We then apply the one-tailed version of Chebyshev’s Inequality to
estimate the percentage of light reaching a surface at depth t. In
particular for the some random variable x drawn from a depth distribution
recovered from the filtered variance shadow map, we have

这样我们应用一个修改版的切尔雪夫不等式去估计光源到达深度t平面的百分比。尤其对于一些从过滤后的方差阴影图得到的随机的变量x ,我们得到:

 

Finally, we use p(t) to attenuate the amount of light reaching the
fragment due to shadowing. Usually it is desirable to clamp the
variance to some minimum value s2
min to avoid any numeric problems
when t 约等于m

最后,我们用p(t)来衰减到达像素的光照总数(因为要算阴影)。常常将方差限制在一个最小值而避免数值不稳定是可取的。

 

3.1 Light Bleeding
Variance shadow maps are simple and efficient, but they suffer from
light bleeding. While Chebyshev’s Inequality gives an upper bound
on P(x  t), there is no guarantee that the upper bound is a good
approximation. As an example, consider the situation shown in
Figure 2.

3.1光照溢出

方差阴影图简单有效,但是有“光照溢出”的缺陷。因为切尔雪夫不等式给出的是每个象素灰度的上限,而又没法保证其上限是一个很好的估计。比如图2所示的情形。

 

Let objects A, B and C be at depths a, b and c respectively. Note
that only objects A and B will be represented in the filter region
since object C is not visible from the light. Thus if we are shading
a fragment at the center of the outlined region, we will recover (1)
the moments
M1 =a+b/2
M2 =a2+b2/2
Then from (2), we compute:
m =b+a/2
s2 =(b

原创粉丝点击