1 giant texture vs. a bunch of smaller ones?

Member
Posts: 35
Joined: 2009.01
Post: #1
Is it best to use as few large textures as possible (ie. go with 1024x1024 and fill em to the brim before moving on)?

Sorry for the very simple question, but this is not the way I've traditionally been doing things, and it seems like it might be better than using a bunch of 128x128 etc.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
It depends. Using a texture atlas can speed things up because you don't need to change texture state as often which can be expensive. The downside is that it prevents you from using repeating textures and can cause bleeding at the edges of the individual images.

Using individual textures might be easier in some cases, and using a texture atlas might be easier in others. It usually pays off to do whatever is easier and optimize later. Doing twice as much work for 20% better performance probably won't double sales. If you are just doing it for fun, go with whatever sounds like a more interesting challenge. Wink

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #3
Seconding what Skorche said. Minimal texture changes can be hugely helpful for performance at times, but not always necessary. If it's easy for you to pile multiple sprites into one texture then by all means do it, otherwise, don't bother unless you need more frame rate.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #4
If you create a texture atlas that has changing textures, be aware that that's a problem on the iPhone, as the texture will be copied, and you could run into a memory problem with multiple atlases changing at once.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #5
If you write your own shaders instead of using the fixed function pipeline, you can recover tiling with an atlased texture by transforming the texture coordinates into the correct space in the pixel shader.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #6
Hrm. I suppose you could, you would just need to add ample bleed-over to the edges so you don't get seams in your mip maps.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #7
Skorche Wrote:Hrm. I suppose you could, you would just need to add ample bleed-over to the edges so you don't get seams in your mip maps.
You would actually need to adjust your mipmaps so instead of going down to 1x1, it goes to 1x1 times the number of tiles you have in each direction. Plus you need a border to make sure that linear filtering doesn't bleed over into the next tile.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #8
You can't solve the filtering problem in the general case (non-centroid anisotropic filtering) by inserting borders.

So it's a tradeoff-- atlases work well for sprite games.
They don't work well for packing discontiguous chunks of textures that will be used in arbitrary 3D situations (light maps, PSX emulation...)

Read Nvidia's whitepaper from 2004.
Quote this message in a reply
Post Reply