# Range of distance in Chebyshev's inequality?

This topic is 2947 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Variance shadow maps employ the Chebyshev inequality to compute the probability of a pixel being in shadow. As per Gpu Gems 3, the code for a Chebyshev upper bound is as such:

float ChebyshevUpperBound(vec2 Moments, float t) { float p = (t<=Moments.x); float Variance = Moments.y - (Moments.x*Moments.x); Variance = max(Variance, 0.00002); float d = (t - Moments.x); float p_max = Variance / (Variance + d*d); return max(p, p_max); }

The article mentions using p_max directly, as the amount of shadowing the pixel receives. This means that 'd', which is the difference between the distance to the light at the world position of the fragment and the distance sampled from the shadow map, directly controls the amount of shadowing applied to the scene.

So, should the depths I'm writing to the shadow map (and the distance I'm passing as 't' to the function) be in the range of 0-1? Or should they just be the actual distances in world space coordinates?

##### Share on other sites
For the code you posted they should be in the range [0,1]. But in principle this doesn't matter - you could use world space distances and the only thing you would need to do is change the minimum variance (from 0.00002 to some scene-dependent number).

Incidentally, Chebyshev's inequality still works if you replace the linear distance with any increasing function of distance. You can also combine multiple different functions together to get better results. I think the best results have been achieved using two functions, exp(x) and -exp(-x). This is described in section 4.2 of Andrew's thesis (http://uwspace.uwaterloo.ca/handle/10012/3640).

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 21
• 23
• 11
• 25