When should I use texture atlases? Do any games at all use them? Whenever I used them, I’ve had problems with bleeding from neighboring texels.
Suggest texture arrays instead. No bleeding, no texcoord math, and still no need to swap textures.
When should I use texture atlases?
The only reason to do so is to cut down on texture binds. So before bothering, you should find out if that’s going to help your application’s performance.
The other reason to use them is to increase batch sizes (which - in fairness - is a consequence that should fall out of reducing texture binds) which will certainly help performance in any non-trivial case. They’re also useful if you’re stuck with non-power-of-2 2D GUI textures and you need to run on hardware that doesn’t have non-power-of-2 texture support.
Yes, games do use them. Any game that has it’s character set in a texture is most likely using a texture atlas to draw characters.
mhagain, I don’t count the character textures. There are no problems with texel bleeding there. It’s just a texture for the unwrapped character mesh. What if I made a texture atlas from a couple of character textures and got bleeding between a couple of them? It almost always happens in unpredictable ways (at least to me). Is leaving blanks between regions of the texture atlas going to solve this?
Leaving blanks (set to r0 g0 b0 a0) and setting the proper blend mode (or using alpha testing) is one way, yes. Another one that’s probably only appropriate to unscaled GUI textures is to use a GL_NEAREST filter mode. Another one is to duplicate the outer edges of each sub-texture in the atlas by 1 texel.
try at least 2 extra texels.