Results 1 to 2 of 2

Thread: removing artifacts in Shadowmap adds some extra shadows

  1. #1
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12

    removing artifacts in Shadowmap adds some extra shadows

    I am trying to implement shadowmap in opengl. I am having some artifacts which i am supposed to have. But while trying to remove that i get some extra shadows

    Code :
    vec4 shadowCoordinateWdivide = shadowCoord / shadowCoord.w ;
        //shadowCoordinateWdivide.z += 0.005;
        float distanceFromLight = texture2D(shadowMap, shadowCoordinateWdivide.xy).z;
        float shadow = 1.0;
        if (shadowCoord.w > 0.0)
            shadow = distanceFromLight < shadowCoordinateWdivide.z ? 0.5 : 1.0 ;
        gl_FragColor *= shadow;
    adding the line
    Code :
    shadowCoordinateWdivide.z += 0.005;
    adds some extra shadows for the planes behind.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,105
    Quote Originally Posted by rakeshmalik91 View Post
    I am trying to implement shadowmap in opengl. I am having some artifacts which i am supposed to have. But while trying to remove that i get some extra shadows
    Using an offset to prevent depth fighting is a fudge. The actual offset needs to be just enough to prevent depth fighting but not so much as to extend the light/shadow boundary into other geometry. It helps if you can minimise the ratio of the far plane to the near plane when rendering the shadow map, i.e. move the near plane as far from the light as possible without it touching the geometry. If you can't manage that, consider using a linear depth buffer.

Similar Threads

  1. Adds unwanted vertex at origin
    By Ploppz in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-04-2015, 09:27 AM
  2. Replies: 2
    Last Post: 10-25-2014, 08:20 PM
  3. basic shadow mapping - removing artifacts
    By Triangle in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-20-2012, 07:14 AM
  4. Stencil shadows artifacts
    By Bibobibobibo22 in forum OpenGL: Advanced Coding
    Replies: 18
    Last Post: 02-29-2004, 10:54 AM
  5. artifacts in stencil shadows
    By break_stuff247 in forum OpenGL: Advanced Coding
    Replies: 10
    Last Post: 01-29-2003, 05:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean