I found that this Shadow technology has almost no detailed explanation in the Chinese version.
Variance shadow maps
William DonnellyAndrew lauritzen
WaterlooUniversity, computer science, graphics lab
Winger_wTranslation
Limited level. Incorrect description. Welcome to point it out.
QQ: 379404629
Figure1: Comparison of different kinds of filters. Upper: normalShadow Map, UsePCF. Below:Varianceshadow MapExploitationMipmappingAnd16x.
Summary
In real-time rendering,ShadowmapsIt is a widely used Shadow technology. A major disadvantage of this technology is that sampling like a normal texture produces severe serrations. This article introduces a new real-time rendering shadowAlgorithm--Variance shadow maps. Different from the traditionalShadow MapSave a depth value. We will save the square of the depth and depth, and use them to calculate the variance of the texture sampling area. Using variance, we can calculate the upper limit of the probability that a pixel is blocked. We can see that this probability value is very close to the soft shadow of reality and can be used for real-time rendering. Our algorithms are easilyGPUOnly a little bit of data needs to be stored.
1 Introduction
Shadow maps [Williams 1987]And shadow(Shadow volumes) [Crow 1977]It is a common shadow rendering algorithm.Shadow mapsCompared with a shadow, a shadow has many advantages. For example, it is easier to execute, less sensitive to model complexity, and has no special geometric space requirements.
unfortunately, like most textures, shadow maps If the filter is inappropriate, the system will produce conspicuous serrations. Modern graphics cards support filtering methods to reduce the Sawtooth produced by normal textures. They are: MIP Mapping . These technologies are not applicable to Standard shadow maps , because it simply adds Shadow Map performs linear interpolation with the surrounding vertices. A typical real-time rendering method is to take the depth values of several adjacent points, compare them in sequence, and average the results. This method is expensive because the video card is not optimized.
For effective solutionShadow mapsWe have noticed the standardShadow MapOnly the depth information of a single vertex is saved. VarianceShadow mapsEach pixel saves the region depth information. To describe this information with a small amount of data, we store two pieces of data: the square of depth and depth. The main advantage of doing so is that we can use it to describe the depth of a region. (This sentence is very good for translation. The original Article is as follows:One major advantage of this representation is that we canapproximate the average of two distributions by averaging the moments.)
Sample varianceShadow MapWe use these two data to calculate a hash value boundary in the region where the current pixel is located. We can see that this boundary value can simulate the Soft Shadows that each light source projected onto any surface.
Because the two data can be interpolated, We can filter out a large range of data based on hardware, just like normal texture sampling, to reduce the amount of data in the sample.
2 Related Research
WilliamsIntroductionShadow mapsThis is an effective shadow algorithm. However, he pointed out that ordinary color texture filtering technology is not applicableShadow maps.
PCF (percentage closer filtering) [Reeves et al.1987]Provides a solution. His essence is to compare the depth information multiple times. This requires multiple texture samples to eliminate the Sawtooth.
Deep shadow maps [lokovic And Veach 2000]Saves multiple depth values of a region to replace the depth information of a single point.Deep shadow mapsIt is difficult to run efficiently on the video card for two reasons: each pixelShadeA large amount of deep data is required. At the same time, it takes additional time to calculate the average value.
Opacity shadow maps [Kim and norann 2001]SimilarDeep shadow mapsThe region depth information is stored, but it is achieved by storing a fixed amount of information. This algorithm has a relatively high efficiency.(I have not studied this algorithm, and the original article is vague, listing:Opacity shadow maps [Kim and norann 2001] encode
Distribution of depths, but use a fixedamount of storage per pixel. each pixel stores a function just as in deepshadow maps, but instead the function is constructed from its values at a fixedset of points. thus the algorithm can take advantage of the speed of graphicshardware. the price to pay for this flexibility is extreme quantization ofdepths, so the technique is mostly suitable for rendering of dense volumetric objectssuch as hair and fur .)
Another solutionShadow MapThe Sawtooth method is to change the projection matrix. They areAdaptive shadow maps [Fernando et al.2001], perspective shadow maps [stamminger and drettakis 2002], light Space Perspective shadow maps [Wimmer et al.2004], trapezoidal shadowmaps [Martin and tan 2004].These algorithms complement the preceding algorithms because they do not have any requirements on the projection matrix.
Video Card supportShadow mapsFor exampleOpenGL "gl_arb_shadow". However, this feature does not support interpolation orMipmapping. SomeNVIDIAThe video card processor supports bilinear filtering.[Everitt et al.2000]But as far as I know, no video card supports the use of Tri-linear or undirected FilteringShadowmaps.
3 Algorithm Overview
In the traditionalShadowmappingFirst, we will render the scene at the light source to save the depth from the light source.Variance shadow mapsWe render a buffer with two channels to save the square of depth and depth. AlthoughShadow MapNo texture filtering method is used to sample depth values,Variance shadow map.
We usedShadow MapSome filtering is done. Including generationMipmaps [willliams1983]Or calculate the data in the accumulated area.(Summedarea tables) [Crow 1984]. Now, ourVariance shadow mapsYou can also blur the shadow.
We store the square of depth and depth into the texture, and the two information will be filtered during sampling. (Note: filtering is actually an average value.) We define the values of these two channelsM1 m2, As shown below:
Using them, we can calculate the variance:
Variance can be understood as a value that describes region information. We can use variance to calculate a probability boundary greater than a certain variable.ChebyshevThe formula is described in detail.
SetXIs a random depth value that changes in the filtering area, and then setT> μ
In the above formulaPDescribes the probability of a region greater than a certain value.TIs the current depth value we need to compare, then,PIt can be understood as the probability in the shadow.
Although, the formula5Only one upper limit is provided. However, it can describe the soft shadow effect in an approximate way.
3.1 Plane shadow
In this case, the depth of a plane block isD1It casts a shadow to another plane. The depth of this plane isD2(Note: when the plane depth is fixed, the surface is parallel and perpendicular to the line of sight of the light source. The interpolation of the two plane depths can be consideredMipmap). If the object is not blocked,D1, D2Mixed ParametersP(Mipmap), Then we can get:
Formula5, We can calculate:
We can see that in this simple scenario,ChebyshevThe value given by the inequality is equal to our filter parameter.
Although this is a special case, it provides an approximate value for most scenarios. In a scenario where there is only a single shadow block and receiver, we only need to sample the depth of the projection or receiver because their error is very small. In this case, the formula5No exact value is provided, but the error is small enough. In this way, we can think thatPmaxIs an ideal approximate value.
4 Implementation
InGeforce6800gtOn implementationVSM.
Geforce6Series video card support16Bit floating point texture, we use hardware-supportedMipmappingAnd various heterosexual filtering.VSM. The steps are as follows:
1.Render16Bit floating point texture, which saves the square of depth and depth.
2.If you like it, we can use the secondPassPerform Gaussian blur on the texture.
3.OpenGLAutomatically GeneratedMipmaps.
4. normal Rendering scenario. We read Shadow Map (depth ), m2 (depth square ). If depth <μ < span> (average depth, that is, m1 ), the pixel is not in the shadow. Otherwise, we use m1 , m2 calculate the variance, use the formula 5 to adjust the illumination.
We also use32Bit floating point texture to saveShadow Map. Because our hardware does not support filtering on this precision, weShaderReturns the bilinear difference. Theoretically, we can stillShaderIn progressMipmappingBut it is very slow.
We can also perform some comparison filtering as followsShadow Map. They are based on16Bit floating point texture.
1.The depth comparison between neighboring points is simple.
2.Compare the four adjacent points and perform bilinear interpolation.
3.Compare the values of four adjacent points with Gaussian blur.
4.Take the four-point comparison and perform bilinear interpolation for each vertex, and then perform Gaussian blur.
5 Conclusion
Figure2Demonstrate usageMipmapping. Just like a normal texture,MipmappingThis effectively reduces shadow sawtooth. The unique filter can also be used.VSMWhen the angle of view is very normal, it can also effectively eliminate the Sawtooth (suchFigure 1).
Figure2: NoneMipmapping(Left)Mipmapping(Right)
Figure3: Left to right:1) StandardShadowmapping,2)5x5 PCF,3)5x5Bilinear FilteringPCF,4)VSMExploitation5x5Gaussian blur
Figure4:When the variance of the filtering area is large, light penetration will occur. The circular area of the car (this figure is too vague to see clearly~~~) Should be a thorough(Solid). Note that the depth varies greatly, so it is easy to see the light penetration phenomenon.
Figure3Demonstrate the use of various filtering methodsVSMComparison of results. We can see thatVSMThe effect is much better.
5.1 Illumination Penetration Problem ( Light bleeding )
OurPmaxIn most cases, it is a small-scale variable. However, it is not an exact value. Slave Formula5We can see that the variance must be greater0, RegardlessDWhy,Pmax (d)Always greater0. When the variance is very small,PmaxIt will soon0So penetration is not so conspicuous. However, when the variance is large, it is likeFigure4In this way, there will be obvious penetration. (The place where the shadow is to be masked and the light is displayed)
In fact, this problem will only happen in scenarios with great changes in depth. In addition,VSMGood job.
5.2 Performance
We chose a single spotlight scenario for variousShadow MapComparison of efficiency, suchFigure1. Because all operations are in the image space, all efficiency is irrelevant to the geometric complexity of the scenario.
VSMWe have adoptedMipmapping,3Linear filtering, and16x. The filtering methods of other algorithms are not supported by hardware.Shader.
InGeforce6800gtThe performance is measured by the number of frames rendered in one second. Let's take a look at the differencesShadow MapSupported, rendered1024x768Color buffer efficiency comparison:
Let's take a look at all sampling512x512OfShadow MapBut the comparison of different target buffer resolutions:
We noticed thatPCFPairShadow MapThe size is not sensitive, but the screen resolution has a greater impact on it. In comparison,VSMImpact on screen resolution and normalShadow MapSimilar. However, if some pre-filter operations are used, suchVsm3x3Then, the screen resolution isVSMThe impact is still very large.
5.3 Digital stability ( Numerical Stability )
Formula for Calculating variance from4We can see some hidden dangers of using floating-point operations. When the variance differs greatly from the average depth, precision is easily lost. During the experiment, we found that this error sometimes occurs in16Bit floating pointShadow MapBut it never exists32Bit texture. We hope the hardware in the future can be supported.32Bit floating point textureMipmappingIt has been filtered by the opposite sex.
6 Conclusion
We have already introduced the variance.ShadowmapIt is a simple and effective method to reduce shadow sawtooth. Our calculation result is based on the upper limit of probability in a region, which can simulate the real soft shadow. Finally, we can seeVSMIt is ideal for modern graphics and compares the performance and quality differences between it and other shadow technologies.
Thanks
ThanksMichaelmccoolAndStefanusdutoitHelp andChrisiacobucciVehicle model provided.