   Shadowmapping problems
As you can, I'm having some problems with shadowmapping.The version I'm implementing is based on this tutorialhttp://www.fabiensanglard.net/shadowmappingVSM/index.phpI've tried added an offset but I always get shadows where they shouldnt be.This is the fragment shader code:float Shadow(){vec4 shadowCoordinateWdivide = shadowCoord / shadowCoord.w;float distance = shadowCoordinateWdivide.z;// We retrive the two moments previously stored (depth and depth*depth)vec2 moments = texture2D(shadowMap,shadowCoordinateWdivide.xy).rg;// Surface is fully lit. as the current fragment is before the light occluderif (distance <= moments.x)return 1.0;// The fragment is either in shadow or penumbra. We now use chebyshev's upperBound to check// How likely this pixel is to be lit (p_max)float variance = moments.y - (moments.x*moments.x);variance = max(variance, 0.0002);float d = distance - moments.x;float p_max = variance / (variance + d*d);return 0.2 + p_max * 0.8;}Besides from this problem, right now I'm not able to convert the shadow coordinates to the right world transform space, so if I use the same model, like in the picture, they all use the same shadow coordinates. I tried transform the coordinates by the model view, but of course, this is not correct, my matrix math is not very good.[Edited by - Relfos on May 31, 2010 12:23:02 PM]
  Anyone?   ;  It is hard to tell by that picture what even looks wrong. I cant tell where the shadows should even be coming from.   ;  The problem is fixed, I forgot that I also need to bias the xy component of the project shadow coordinates, not just the z.   