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: VSM Shadows inverted falloff

Hybrid View

  1. #1
    Newbie Newbie
    Join Date
    Apr 2013
    Posts
    1

    VSM Shadows inverted falloff

    Hi,

    I am trying to implement VSM Shadow Maps with OpenGL 3.3.
    Everything worked fine so far but now I have the same problem as OniDaito who created this thread in 2011: http://www.opengl.org/discussion_boa...lloff-inverted

    My VSM code is based on this tutorial (fabiensanglard.net/shadowmappingVSM/index.php) and it's basically plain VSM with a Gussian blur applied to it.

    Fragment Shader:
    pastebin.com/TgbZFcCf

    If I use "return max(p_max, 0.4);" in chebyshevUpperBound(), I get this result:
    s24.postimg.org/93zm0skpx/image.jpg

    If i use "return max(1.0 - p_max, 0.0);", this result: (proposed in the above mentioned thread from 2011)
    s21.postimg.org/9o7ahhux3/image.jpg

    The first one looks pretty good but the gradient/falloff is inverted. (The shadow is bright close to the object and dark farther away)

    Has anyone an idea on how to fix this?
    Thanks.

    PS: I am sorry for not using [IMG] and [CODE]. The forum complained always about "too many URL's and forbidden words". Probably a mod can fix this when he sees it.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    800
    Hi,
    You are not dividing the shadow coords by w. The varable d in you fragment shader code should use the z shadowmap texture coordinate after homogeneous division (divide by w) i.e.
    Code :
    vec tmp = ShadowCoordPostW.z/ShadowCoordPostW.w;
    d = tmp.z - moments.x;

    I think probably your shadow texture coordinate calculation is messed up. Could you show us how you are setting up the shadow coordinates calculation? You should multiply the world space position of each object with the shadow matrix S.

    On a side note, you have to also check for the w coordinate value to be > 1 otherwise you will have back projected shadows.
    Last edited by mobeen; 05-14-2013 at 09:57 PM.
    Regards,
    Mobeen

Posting Permissions

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