Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: textureGather sampling artifacts.

  1. #1
    Super Moderator Frequent Contributor Groovounet's Avatar
    Join Date
    Jul 2004

    textureGather sampling artifacts.


    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:	388 
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?


  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Do you get exactly the same results on nVidia and AMD; because I would expect slightly different results with a sampling error.

  3. #3
    Super Moderator Frequent Contributor Groovounet's Avatar
    Join Date
    Jul 2004
    It's similar but not exactly the same.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts