# The math behind Variance Shadow Maps - moments

I am not asking how to implement them (that's not particularly difficult), but I'm having a bit of trouble understanding why the moments used in Chebyshev's inequality (indirectly) are equal to the depth value and the depth squared respectively.

To grasp why things are like this, I tried to understand what the random variable one computes the moments for is, and what is its density (the p(x) in those integrals used to compute the moments). Now that one can equate the moments to the depth and depth^2 is the magic behind this approach, hence the key of justifying it mathematically. Can anyone please explain what p(x) is, and why is the first moment equal to the depth value? I can probably pick up from there and easily understand the second moment.

## 1 Answer

p(x) there is the blur kernel, usually a Gaussian, with which you convolve the depth and depth^2 buffers. (Or if you don't do a Gaussian blur on the VSM, then it's just the bilinear filtering kernel.) The random variable is, correspondingly, the depth of a random point in the shadow map chosen with a Gaussian distribution around the point whose shadow you're evaluating.

I think the notation in the article is misleading because it makes it appear the integrals are one-dimensional, but in fact they are two-dimensional, done over the blur kernel's support in the shadow map's UV space.

• thanks. I also figured they were talking about double integrals, but computer science papers usually abuse formulas on a regular basis. What you're saying really explains a lot.. this approach can be used for basically anything (not just depths), if p(x) is the convolution kernel.. leaving you with a nifty trick for soft feature representation. Thanks again.. – teodron Aug 16 '13 at 6:51