Texture has white dot line edge!

Hi all,

when i draw a texture, its four edges also show(four white dot lines), how to let these edges do not show?

BTW: If both the width and height of the texture’s original picture are two to the power of N,(ie, 12864, 256256), then there are no edges appear, but if either of the width and height of the picture is not two to the power of N, (ie, 4032, 120120), then when i draw the texture, there are four edges shown. How to solve this problem? Thanks a lot!

You should say that you use OpenGL ES, and that you can not use NPOT textures.

This is due to linear interpolation. If you use nearest interpolation, the problem should disappear but it is not a good solution.

Texcoord clamping can not work in this case, so either you clamp yourself on the fragment shader (not possible on GL ES < 2), either you manually duplicate the 4 line of texels around your “valid” part. It must be done on each mipmap level by the way.

Alternatively, if you’re creating the content yourself, why not make the while thing a lot easier by just resizing the images to powers of 2 in an image editor? You’ll likely get higher quality than if you did it in the app, and it’ll create less overhead when rendering.

Hi ZbuffeR,

I changed GL_LINEAR parameters in the following codes to GL_NEAREST, it really works.

glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); //GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); //GL_LINEAR);

“so either you clamp yourself on the fragment shader (not possible on GL ES < 2)”
My hardware only supports GL ES 1.0, so i can’t use this method.

“either you manually duplicate the 4 line of texels around your “valid” part. It must be done on each mipmap level by the way.”
sorry for that i dont understand this paragraph and dont know how to do it.

Thanks!

let’s try ascii art :
your current texture is like this, with ‘0’ texels being undefined (because only here to make a POT texture) and X and 123456789A your data :


XXXX1000
XXXX2000
XXXX3000
XXXX4000
XXXX5000
A9876000
00000000
00000000

To avoid linear sampling from undefined texels, you have to do this :


XXXX1100
XXXX2200
XXXX3300
XXXX4400
XXXX5500
A9876600
A9876600
00000000

And use GL_CLAMP_TO_EDGE for S and T wraping.

Hi mhagain,

If i resize images to powers of 2, i think that will change their shape.
Thanks!

Hi ZbuffeR,

I understand now, thanks very much!