texture border = black mipmaps

I noticed something strange when I tried setting texture border to 1:

The mipmaps turn black. Stays black even when I set the border color to another color. Only happens when I set the ‘border’ argument on glTexImage2d to ‘1’ on level 0 mipmap, no effect whatsoever otherwise (texture is rendered normally).

Admittedly, I have never tried texture borders, I don’t know what the exact results should be, but I doubt this effect is desirable?

GLSL shaded terrain, texture is GL_REPEAT wrapped, otherwise nothing out of the ordinary.

GF8800GT, ForceWare 174.74, WinXP

Only happens when I set the ‘border’ argument on glTexImage2d to ‘1’ on level 0 mipmap

Huh? And how do you generate the texture levels >0 which all require border texels as well?
That is, if your LOD 0 is 4x4 without borders you download (4+2)^2 for that with borders, then (2+2)^2, then (1+2)^2 textures for the other levels and you better generate the borders on those “manually”.
REPEAT filtering will not actually access the texture borders anyway which means your case somehow screwed up the mipmap generation by mixing in black from somewhere.

Texture border texels have precedence over the texture border color. If you specify glTexImage with border = 1, the texture border color is irrelevant.

Sorry I didn’t explain that very well.

I have a perfectly working texture loader, mipmaps are automatically generated (GL_GENERATE_MIPMAP_SGIS). I now change border argument to 1, which results into black mipmaps.

I was under the impression that texture borders would be magically added and I didn’t have to change any data passed to glTexImage2d, this is correct? And this border would be the color I passed as GL_TEXTURE_BORDER_COLOR, which I can change at any time. Or is this a misunderstanding?

I mentioned REPEAT filtering, because I’ve read that when wrapped, borders should have no effect, yet it does ruin my mipmaps. :frowning: No GL errors raised, and the texture semi-works, if the texture was incomplete for some reason it would be white.

So I’m really just wondering if GL_GENERATE_MIPMAP_SGIS supports texture borders at all (I suppose it should) but I can’t find any spec…

It should. Sounds like a driver bug.

But in general, you shouldn’t use texture borders, as most hardware doesn’t support them.

What Relic meant is that mipmaps are only well defined for power-of-two textures if you use automatic mipmap generation. You may want to check out glGenerateMipmapEXT for more control over this. Anyway. If you’re using 256x256 image data now without borders, then you should supply (256+2)x(256+2) pixels when using border so that the area without borders is once again a power-of-2.

Also, like Relic already mentioned, the border color is always present. So even if you don’t specify a border of 1 when creating a texture, you will still sample the border color if the wrapping mode allows it. The only difference when setting borders manually is that you sample the border pixel you provided instead of the constant border color.