Jump to content
  • Advertisement
Sign in to follow this  

OpenGL very small variance value from Variance Shadow Mapping

This topic is 1485 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

Sorry, it was a bug in my code. How can I delete the thread?


Hi, I'm trying to implement Variance Shadow Mapping, but get very small variance and Chebychev's upper bound, which results in sharp shadow edges. And I've turned on OpenGL texture linear filtering. Could anyone help out on this? Thanks.


#version 400

layout(location = 0) out vec2 moments;

void main()

      float depth = gl_FragCoord.z/*  * 0.5 + 0.5 */;

      float moment1 = depth;
      float moment2 = depth * depth;

      moments = vec2(moment1, moment2);
float chebyshevUpperBound(vec3 shadowPos)
vec2 moments = texture(shadowMap[0], shadowPos.xy).rg;

float bias = 0.000028;
if (shadowPos.z - bias <= moments[0])
return 1.0 ;

float variance = moments.y - (moments.x * moments.x);
variance = max(variance, 0.00002);

float d = v2fShadowPos.z - moments.x;
// this value is really small !!!!
float p_max = variance / (variance + d * d);

return p_max;
Edited by sobeit

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!