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 4 of 4

Thread: Need help with Variance Shadow Mapping technique

Hybrid View

  1. #1
    Newbie Newbie
    Join Date
    Nov 2012
    Posts
    3

    Need help with Variance Shadow Mapping technique

    Hello everyone.

    I'm trying to make a small demo of VSM technique to learn it. I'm using OpenGL 2.0 + framebuffer extension, also using SDL and GLEW for utility. I've got some visual problems, looking like that:
    (clickable image link to imgbox.com, image host)


    After searching information on this forum, i've found a trick of clamping minimum value of (M2 - M1*M1) by 0.00002. It makes shadow look much better, except certain angles, which still look like that:
    (clickable image link to imgbox.com, image host)


    If I increase this minimum value, artifacts become less visible, at the same time shadow becomes fainter (probably that's why artifacts less visible too).

    I have done blurring after second test. While it helped, some artifacts are still visible:
    (clickable image link to imgbox.com, image host)


    Full source code (tested on Gentoo Linux 64bit) is here: http://pastebin.com/iAkeW85V
    I know it's not optimized in any way, and many textures/fbos could be reused and some textures combined, i'll do it later, for now I want to get rid of artifacts. Please help me to get rid of them.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    719
    Hmm, where is the light source in your second and third image (from the shadow I would guess it is a point light somewhere above the box)? Shouldn't the sides of the box then be not lit? In other words can you only do shadow lookups in your shader when the fragment is actually receiving light from the shadow casting source? That should get rid of those artefacts on faces that are not facing the light source.

  3. #3
    Newbie Newbie
    Join Date
    Nov 2012
    Posts
    3
    I have checked your guess. My cube's points are:
    top side:
    ( 1.0f, 2.5f,-1.0f)
    (-1.0f, 2.5f,-1.0f);
    (-1.0f, 2.5f, 1.0f);
    ( 1.0f, 2.5f, 1.0f);

    bottom side:
    ( 1.0f, 0.5f, 1.0f);
    (-1.0f, 0.5f, 1.0f);
    (-1.0f, 0.5f,-1.0f);
    ( 1.0f, 0.5f,-1.0f);

    When light's position is about (1.0f+-0.02f, 6.0f, 1.0f+-0.02f) (it's almost right above vertical edge of cube), I get this artifact on 2 sides. But, when x and z coordinates are from 1.0f to 1.02f it should be lit, and when they're from 0.98f to 1.0f it should give soft shadow.

    I'm not too much familiar with lightning and shadows calculations, I was doing VSM basing on information from this site: http://www.punkuser.net/vsm/ (actually, this paper: http://www.punkuser.net/vsm/vsm_paper.pdf).

    I've found that floating-point texture usage would produce less artifacts. I'm not sure if GL_DEPTH_COMPONENT32 is floating-point texture. As far as I could find information, it is not (I can be wrong here), so I'll try other texture formats tomorrow and see if this will help me to get rid of artifacts.

  4. #4
    Newbie Newbie
    Join Date
    Nov 2012
    Posts
    3
    Finally I've got a bit of spare time to try floating-point textures. As i've found out, using GL_DEPTH_COMPONENT32F or GL_RGBA32F (floating-point texture formats) doesn't reduce artifacts. Yes, they can contain numbers outside of [0; 1] range, but (as i've found in documentation) they are don't necessary have better precision. Any ideas how to get rid of those artifacts visualized in first post are welcome.

Posting Permissions

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