PDA

View Full Version : Texture has white dot line edge!



davie
07-22-2010, 08:19 PM
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, 128*64, 256*256), 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, 40*32, 120*120), then when i draw the texture, there are four edges shown. How to solve this problem? Thanks a lot!

ZbuffeR
07-23-2010, 02:43 AM
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.

mhagain
07-23-2010, 04:05 AM
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.

davie
07-23-2010, 04:35 AM
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.

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!

ZbuffeR
07-23-2010, 04:43 AM
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.

davie
07-23-2010, 04:49 AM
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 mhagain,

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

davie
07-23-2010, 05:39 AM
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 ZbuffeR,

I understand now, thanks very much!