PDA

View Full Version : Problems with textures and borders



luisillo
07-10-2006, 02:31 AM
I have a problem with my textures. It seems as it has a border. I think that the colour of the border is take from the texture. The coordinates of the texture i'm using are between 0 and 1 (i control this).

I use this for create textura, so i don't use any border.

glTexImage2D ( GL_TEXTURE_2D,0,GL_RGB4, Width, Height, 0,GL_RGB, GL_UNSIGNED_BYTE, data);
Image (http://img215.imageshack.us/img215/8076/opengltexturepoblem5lu.jpg)

Thanks

memfr0b
07-10-2006, 02:56 AM
If you image data doesn't specify border pixels, a single border color (which defaults to black) is used. The texture coordinates 0 and 1 fall right in the middle between the left/bottom border and the first pixel, and the last pixel and the right/top border. Thus the combination of a texture withou border and GL_CLAMP texture wrap mode causes the outer edge of the texture to be blended with a constant border color. That's what you see in the screenshot.

You can fix this by
Providing explicit border pixels that copy the adjacent edge of the neighboring texture. Specifying texture coordinates from 1/2n to 1-1/2n, where n is the texture width/height in pixels. Using texture wrap mode GL_CLAMP_TO_EDGE, which limits the texture coordinates to the range mentioned above.

luisillo
07-10-2006, 03:06 AM
Thanks alot!