Does anyone know some tricks (shaders) to put repeating textures (wrap mode GL_REPEAT and tex coords outside the range [0, 1]) into texture atlases (in order to reduce the number of texture switches) that work with MIPMAPPING, too?

ZbuffeR

01-16-2006, 02:03 PM

Texture atlases can never work properly with mipmapping.

execom_rt

01-17-2006, 03:08 AM

There is indeed a problem with texture atlas, more exactly the 'texture bleeding' problem.

It works fine for font page, sprites, where usually border between bitmap is black and alpha is zero, but for texture altas with different textures, it's more problematic.

One solution is to use anisotropic texture filtering that reduce a lot the texture bleeding problem, but it is not perfect.

There is a white paper (http://download.nvidia.com/developer/NVTextureSuite/Atlas_Tools/Texture_Atlas_Whitepaper.pdf) about this subject.

killerseven

01-17-2006, 03:00 PM

The trick is to create your mipmaps from the original textures and then create your atlas (ie you cannot make your mipmaps from the atlas).

This doesn't solve the problem but it does minimise it, and with some care it can work ok.

As for your original question about wrapping, that is easily acheived in a fragment shader.

Upload the coord boundaries of your texture within the atlas. In your fragment shader just modulate the varying texcoords to the boundary.

Hampel

01-17-2006, 11:40 PM

Thanks to all.

The repeating problem without mipmapping has already been solved (we used the suggested solution).

gl_FragColor = gl_Color * texture2D(texture, texCoord);
} But we have models with several 10s or 100s of (small) repeating textures which really sucks without mipmapping (if viewed from the distance).

How would anisotropic filtering help? Wouldn't this leed to even more texture bleeding artefacts?

killerseven

01-18-2006, 09:23 AM

It explains everything in the paper execom_rt linked to.

The mipmapping issue can be solved relatively easily. The only real issue is with artifacts caused by the bilinear filtering of the textures (see p13 of the paper). Anisotropic filtering would improve things because it wouldnt take as much colour from neighbouring dirty pixels.

You could solve the problem entirely by disabling texture filtering and doing your own (clamped) bilinear filtering in the pixel shader. But then I imagine it would be faster to just change textures.