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

Thread: basic shadow mapping - removing artifacts

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    24

    basic shadow mapping - removing artifacts

    I implemented a basic shadow mapping. I have a scene illuminated by one directional light.
    I use an orthographic projection:
    Code :
    (glm::ortho(-70.0f, 70.0f, -50.0f, 90.0f, -50.0f, 100.0f));

    which is sufficient to cover the scene from the light point of view. LightViewMatrix looks like this:
    Code :
    glm::lookAt(glm::normalize(glm::vec3(0.0f, 1.0f, 1.0f)), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));

    Here are parameters for a depth texture:
    Code :
    glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);

    In a shader I use sampler2Dshadow so I get a basic PCF filter.

    I removed an ambient light and artifacts are more visible. First I used front face culling during saving depth values. That removed artifacts
    from the illuminated part of the object, but then I got many artifacts in the shadow.
    Image1

    Next I set glPolygonOffset(4.0f, 20.0f) during saving depth values instead of the front
    face culling and I got better results but some artifacts were still visible in the shadow:
    Image2
    and in the light:
    Image3

    I read that glPolygonOffset gives better results than using a constant bias in the shader because
    it takes into account a polygon slope.

    1. Is it possible to calculate a dynamic bias in the shader which gives better results than glPolygonOffset ? (How to do it ? )
    2. Is something what I can do better to remove artifacts using only the basic shadow mapping concept or the only way is using more advanced techniques such as cascaded shadow mapping etc. ?
    Last edited by Triangle; 11-06-2012 at 10:59 AM.

Posting Permissions

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