Hello,
I’m getting some result with texture coordinates that I don’t understand.
I’m rendering a quad with texture coordinates (0,0)(1,0)(1,1)(0,1) and a 2x2 texture.
If I discard all fragments with texcoord.x>=0.5, I expect to see only the left part of my texture. Instead I’m seeing a small part of the right side. http://tinypic.com/r/fpbllw/7
My shader looks like this:
I only get this result on ATI, not NVIDIA.
The “error” is very high because sampling texture like this:
gl_FragColor = texture2D(tex, vec2(0.4999, 0.));
already fetchs texel at image pos (1,0).
What is the expected result? Do you see how to fix this?
Thank you.
Edit: Texture is in nearest mode.
Sorry, the picture is indeed not clear.
What you are seeing is a quad on which a 2x2 texture is applied (with filtering set to nearest).
Texel (0,0) is red, Texel (1,0) is green
Texel (0,1) is blue, Texel (1,1) is yellow
I’m discarding all fragment whose texture coords are >= 0.5. Thus I’m expecting to see only red and blue. Instead, I see a small border with green and yellow.
My question can be reduced to: Why on a 2x2 texture in nearest mode, texture2D(tex, vec2(0.4999, 0.)) fetchs texel(1,0)?
On ATI(HD5870) at least. Thank you.