My rendering is bleeding pixels (the dots in red) along the edge of these two perpendicular quads.
I'm using:
GL_NEAREST
min/max texture filtering.texture
function on fragment shader.- A sprite atlas of 1024x1024, with the desired sprite @ (x=320,y=732,width=8,height=8)
s1 = 320.0f/1024.0f;
s2 = (320.0f+8.0f)/1024.0f;
t1 = 732.0f/1024.0f;
t2 = (732.0f+8.0f)/1024.0f;
Render #1 (with a dark texture to make it easier to see bleeding):
Render #2: (with bright texture for counting texels, but the red pixels are still present):
I understand that OpenGL's texture
function will sample at the pixel center, but when I try to offset the "S,T" coordinates by half-a-pixel, it (fixes it but) has adverse effects.
For example, the texture coordinates below shrinks the width of the texels along the border of the sprite.
s1 = (0.5f+320.0f)/1024.0f;
s2 = (0.5f+320.0f+8.0f)/1024.0f;
t1 = (-0.5f+732.0f)/1024.0f;
t2 = (-0.5f+732.0f+8.0f)/1024.0f;
I tried a bunch of possible S&T offset combinations (adding 0.5 to both S&T, subtracting from both, adding to T but subtracting from S) and different values, none of it worked. I don't know what I'm missing; I don't think this is a T-junction issue because the bleeding pixel color is coming from the texture (not the background).