Sign in to follow this  

OpenGL very small variance value from Variance Shadow Mapping

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this