I am trying to use textureGather to build a custom shadow filter but I am running into sampling artifacts that I presume are due to precision issues (both on AMD and NVIDIA).

The following zoomed screenshot shows the issue:

Click image for larger version. 

Name:	sampling.jpg 
Views:	339 
Size:	5.3 KB 
ID:	978

Here is the code I use to generate this image:

Code :
#version 400 core
uniform sampler2D Diffuse;
uniform sampler2DShadow Shadow;
in block
	vec4 Color;
	vec4 ShadowCoord;
} In;
out vec4 Color;
void main()
	vec4 Diffuse = In.Color;
	vec4 ShadowCoord = In.ShadowCoord;
	ShadowCoord.z -= 0.005;
	vec4 Gather = textureGather(Shadow, ShadowCoord.xy, ShadowCoord.z);
	ivec2 ShadowSize = textureSize(Shadow, 0);
	vec2 TexelCoord = vec2(ShadowCoord.xy) * vec2(ShadowSize.xy);
	vec2 SampleCoord = fract(TexelCoord + 0.5);
	float X0 = mix(Gather.x, Gather.y, SampleCoord.x);
	float X1 = mix(Gather.w, Gather.z, SampleCoord.x);
	float Visibility = mix(X1, X0, SampleCoord.y);
	Color = vec4(mix(vec4(0.5), vec4(1.0), Visibility) * Diffuse);

I think the issue lands on a precision issue before the fract as it seems that SampleCoord wrap around. It could when I add 0.5 as just slightly changing (+ or -) this value introduces more artifacts.

Any idea to remove this sampling artifacts?