TextureAtlas class added to engine

I added a TextureAtlas class to svn that allows batching textures and with its helper methods whole scenes to one geometry that uses a created texture atlas:







In the image you see one geometry made out of a bunch of models and a quad that shows the texture atlas that the geometry uses. Check out the TestTextureAtlas class to play around with it.



A known issue is wrapped/repeated textures will not work (yet) as they require some additional shader work to be repeated properly. If anyone feels like tackling that issue too go ahead :slight_smile:



Cheers,

Normen

6 Likes

awesome :slight_smile: is there limitation of image size? :> like in other engines/games it depends of graphics card

Exactly, like in any engine it obviously depends on the graphics card.

Repeating will never work flawlessy, if you do not introduce additional vertexes.

You will always have a glichy transition, since all mipmap and texturefiltering that are standart fail when doing so. This is the reason I asked for Texturearray support first.



Of course I would be happy if you prove me wrong. (And if not there could be a additional similar class that creates a arraytexture instead)

@EmpirePhoenix said:
Repeating will never work flawlessy, if you do not introduce additional vertexes.
You will always have a glichy transition, since all mipmap and texturefiltering that are standart fail when doing so. This is the reason I asked for Texturearray support first.
Of course I would be happy if you prove me wrong. (And if not there could be a additional similar class that creates a arraytexture instead)

Well there is some options to counteract the mipmapping issue you mention. It would maybe require partially repeating the texture on the atlas already (depending on how the actual texture coordinates look) or at least leaving a border with a "clamped" bit of the texture. But you are right its an issue, thats why its not in yet ^^

For all who don't understand what he means: Textures will bleed into each other at the atlas tile borders when the mipmapping / scaling happens. So you might get visual seams on the models texture border when you zoom out. For models that use only texture coordinates from 0-1 like in the screenshot that doesn't matter much though as they mostly have a border around the actually used parts.

Actually thats not the issue I mean, the cards internal textureunits do some sort of filtering, even when disabling mipmapping at all and using a 2x2 pixel full white textures you will see those seams. (At least I tested at a Radeon HD 3750 and a 6800 series card, after that I tried severall stuff with the shader, and finally gave up.



(Just try it, let the shader repeat a texture severall times without the use of the Repeat mode for texturewrap(as it would not be aviable for texture atlas))

Yes. That part is not hard to understand. A texture coordinate of 2/2 would be on the next tile of the atlas, hence you don’t see it repeat but see some other texture. A separate coords or texture map that contains the tile coordinates could for example be used to avoid this issue so the shader knows when its crossing tile borders. The bleeding issue happens on the borders of each tile and can mostly be avoided by adding borders to the atlas tiles (up to a certain downscaling factor).

Cool! It would be still more cool with AO batching.