   Shadow map error.
  Hello friends: I am working on an important project and I have serious problems when designing the shadows to take the game. Using OpenGL and GLSL for the management of the shadows. In the picture you can see what the problem is and the source code that was taken from a tutorial http://www.GameTutorials.com. http://www.artisticsoft.com/sitiodepruebas/Problema.jpg[VERTEX SHADER]varying vec4 projCoord;void main(){vec4 realPos = gl_ModelViewMatrix * gl_Vertex;projCoord = gl_TextureMatrix[0] * realPos;gl_FrontColor = gl_Color;gl_Position = ftransform();}[FRAGMENT SHADER]uniform sampler2DShadow ShadowMap;varying vec4 projCoord;void main (){const float kTransparency = 0.3;vec4 color = gl_Color;float rValue = shadow2DProj(ShadowMap, projCoord).r + kTransparency;rValue = clamp(rValue, 0.0, 1.0);vec3 coordPos  = projCoord.xyz / projCoord.w;if(coordPos.x >= 0.0 && coordPos.y >= 0.0 && coordPos.x <= 1.0 && coordPos.y <= 1.0 )   {gl_FragColor = color * rValue;}else{gl_FragColor = color;}}Please I need urgent help. Thank you very much.   
  Maybe thats the border line for the end of the shadow map?   ;  The border line? And how could I do to delete it?   ;  If you are using orthographic projection, try increasing the dimension of the view-volume, when creating the projection matrix.   ;  What should be modified for increasing the size of the view-volume? 1 - gluLookAt(L[0]->position[0],L[0]->position[1],L[0]->position[2],0,0,1,0,0,1);2 - gluPerspective(45.0f, SHADOW_WIDTH/SHADOW_HEIGHT, 0.1f, 1000.0f);3 - const float mBias[] = {0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0,0.0, 0.0, 0.5, 0.0,0.5, 0.5, 0.5, 1.0};glMatrixMode(GL_TEXTURE);glLoadMatrixf(mBias);glMultMatrixf(g_mProjection);glMultMatrixf(g_mModelView);glMultMatrixf(g_mCameraInverse);;  You are using perspective projection. In that case, try what happens if you increase the fov, which is 45.f in your example.   ;  If for example 60.0f increase the shadow of the object that is at the heart deforms. and is not as accurate as today, but the error disappears.There will be some mener filter the pixels in the fragment shader to eliminate those who have not been rendered?;  Can you post another screenshot?In the meanwhile I suggest that you decrease the zfar (1000.f now) value and maybe increase the znear (0.1f now) slightly. Of course I don't know the scale of your scene, but it could help.   ;  That could simply be the edge of your shadow map. Whenever I do shadow mapping, I draw the bounding frustum of the light and the view camera, it helps debug these sorts of problems.If this is infact the the edge of your shadow map, I get around this problem by using a spot-mask for the light, this is a greyscale texture which fades out from white in the centre to black at all points on the edge. Then, when sampling the depth map, I also sample this mask, the mask value influences shadow intensity, 0.0 being no effect, 1.0 being full effect.The result is that as your shadow map sampling reaches the edge of the shadow map, the shadows produced fade out and any area outside the shadow map is not affected (i.e. not completely black).Here is a small screenshot of an implementation of mine.Hope that helps,-Danu   