Jump to content
  • Advertisement
Sign in to follow this  

Range of distance in Chebyshev's inequality?

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

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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).

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!