I have implemented shadow mapping, all works fine except that self-shadows are not rendered correctly, as you can see in the picture:


The problem looks like z-fighting, does anybody know how I can solve it?

Here my lookup function:

Code :
float lookup( )
{
    float shadow;
    float depth = texture( shadowMap, ShadowCoord.xy ).x;
 
 
    shadow = ShadowCoord.z > depth ? 0.25f : 1.0f;
 
    return shadow;
}

Thanks in advance