Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

When I want to use texture atlasing, should I try to place all of my sprites into one single texture atlas? Or are there times when I should have multiple smaller texture atlases?

share|improve this question

2 Answers 2

up vote 7 down vote accepted

Like many things in software, it's a balancing act. Fewer texture swaps is good, but getting textures that are too large can also hurt performance. Additionally, sprite sheets with a large number of sprites can be difficult to manage logistically.

To help manage larger sprite sheets, it's recommended that you keep your sprites separate, then join them into a sprite sheet for use in your game. You can use tools (both of which have very clever names) like:

Using these tools will allow you to ensure that animations that belong together end up on the same sprite sheet. That way you're not switching between textures mid animation.

Unfortunately there's no universal standard for maximum texture size. Not only that, but it varies from hardware to hardware, not just between graphics platforms. There are maximums that the graphics platforms can support though, but it doesn't mean the hardware supports it. Be sure to create a check with your game to ensure that you won't load a texture that's too large.

share|improve this answer
    
I intend to make a cross-platform game (desktops mainly, though possibly iOS). How much should I expect the maximum texture size to vary? –  Aaron Jun 28 '12 at 22:30
1  
I don't know much about the mobile limitations. For desktops it really depends on what range of hardware you want to support. I think 2048x2048 is a good middle to high number that most desktops would support. For iOS this thread looks promising. –  Byte56 Jun 28 '12 at 22:44
    
Why add a unnecessary tool to the content pipeline when you can create the texture atlases just as well at run time via glTexSubImage? –  API-Beast Jun 28 '12 at 23:46
    
Not to mention that you can be way more flexible that way because you can query the maximum texture size and don't have to guess. –  API-Beast Jun 28 '12 at 23:51
3  
(1) TexSubImage is often hellishly slow at runtime - you need very careful parameter selection; (2) you still need a method of selecting where images go in the atlas which TexSubImage will not give you; (3) TexSubImage will not solve the problem of which sprite sheet to put which image(s) on; (3) TexSubImage does not give you the ability to query the max size - glGet does and can still be used even with an external tool. –  Darth Satan Jun 29 '12 at 0:23

The fewer textures the better. So one big one would be best. However, depending on your platform and language there is a size limit to an image. So if 2048 x 2048 px is the largest your image can be and your texture atlas is bigger than that, it would be best to have two smaller atlases.

share|improve this answer
3  
+1, and - if you need more than one atlas - make sure that you group images that are going to be used together into the same atlas, otherwise each draw call may need to switch from one atlas to the other and the whole exercise will gain you nothing. –  Darth Satan Jun 28 '12 at 20:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.