rakeshmalik91

08-18-2013, 07:27 AM

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

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

shadowCoordinateWdivide.z += 0.005; adds some extra shadows for the planes behind.

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

shadowCoordinateWdivide.z += 0.005; adds some extra shadows for the planes behind.