Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: variance shadow mapping problem

  1. #1
    Junior Member Regular Contributor
    Join Date
    Sep 2006
    Location
    thailand
    Posts
    130

    variance shadow mapping problem

    I have some question regarding implementing variance shadow mapping

    I follow the NVIDIA GDC slide and implement variance shadow mapping function as follow

    Code :
    //setting
    1.used GL_RGBA32F_ARB to store depth & depth^2 
    2.the resolution of shadow map is 512*512
    3.near and far plane for both scene and depth rendering is 1 and 500
    4.used seperate guassian blur to blur the depth & depth^2 texture

    Code :
    float getLightContribution(vec4 shadowCoordinateWdivide)
    {
     
    	float dist_to_light = shadowCoordinateWdivide.z;
    	vec2 moments = texture2D(shadowTexture,shadowCoordinateWdivide.xy).rb;
    	float litFactor = 0;
    	if(dist_to_light <= moments.x){
    		litFactor = 1.0;
    	}
     
    	//float variance = 0.00000001;
    	float variance = moments.y - (moments.x*moments.x);
     
    	float m_d = moments.x - dist_to_light;
    	float p_max = variance / (variance + m_d*m_d);
     
    	return max(p_max,litFactor);
    }

    and I get no shadow whatever but if I replace variance calculation with some small fix value
    like "float variance = 0.00000001" , the shadow appeared and look somewhat correct.

    But I doubt this is correct since I ignore the whole variance calculation.

    Can somebody explain this to me since there are no mention of this problem in the GDC slide.

    my video card is ATI4670 with 9.12 driver

    this is the image when shadow work (using variance = 0.00000001).


    this is the image when shadow didn't work (calculate variance as it suppose to be).

  2. #2
    Junior Member Regular Contributor
    Join Date
    Sep 2006
    Location
    thailand
    Posts
    130

    Re: variance shadow mapping problem

    I have found the problem .

    I store depth^2 in green channel not the blue one but call
    vec2 moments = texture2D(shadowTexture,shadowCoordinateWdivide.xy ).rb;
    (got the code from this tutorial http://fabiensanglard.net/shadowmappingVSM/index.php)

    which is wrong.

    I now follow the tutorial and add
    variance = max(variance,0.000002); like he suggest and the shadow look beautiful (with out this line the shadow look very grainy).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •