iDevGames Forums
1 giant texture vs. a bunch of smaller ones? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: 1 giant texture vs. a bunch of smaller ones? (/thread-71.html)



1 giant texture vs. a bunch of smaller ones? - daveh84 - May 7, 2010 07:55 AM

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.


1 giant texture vs. a bunch of smaller ones? - Skorche - May 7, 2010 09:07 AM

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


1 giant texture vs. a bunch of smaller ones? - AnotherJake - May 7, 2010 10:35 AM

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.


1 giant texture vs. a bunch of smaller ones? - DoG - May 7, 2010 11:26 AM

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.


1 giant texture vs. a bunch of smaller ones? - akb825 - May 7, 2010 09:29 PM

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.


1 giant texture vs. a bunch of smaller ones? - Skorche - May 8, 2010 08:32 AM

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.


1 giant texture vs. a bunch of smaller ones? - akb825 - May 8, 2010 10:14 AM

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.


1 giant texture vs. a bunch of smaller ones? - arekkusu - May 8, 2010 10:48 AM

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.