Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

When to use sprite sheets?

A topic by 40wattstudio created Sep 07, 2022 Views: 397 Replies: 5
Viewing posts 1 to 2
(+1)

Can anyone tell me what the benefit of sprite sheets are?

Is there a point where sprite sheets become necessary compared to loading in images individually? 

Conversely, are there certain cases where sprite sheets wouldn't be beneficial?


I've heard a little bit on this topic, but would like to hear more from the actual indie community on what your findings and experiences are.

(1 edit) (+3)

If you’re using hardware acceleration, you’re limited to a maximum of 32 texture slots - That’s 32 textures per draw call. And that’s the maximum; Mobile GPUs may have as little as eight slots. If you combine textures onto one single texture, you avoid this issue completely. Of course you could also use a texture array… The problem with texture arrays is each texture has to be the same size.

For software rendering, the CPU can copy regions of pixels faster if they’re close together in memory, which is automatically the case with a sprite sheet/texture atlas.

Thanks for the response! So if I'm understanding you correctly, sprite sheets would be more important for games -- especially mobile -- that use the GPU? 

(+3)

Yes, though I feel like I need to make an addendum to that.

  1. The vast majority of games, game engines, and frameworks today are rendering with the GPU. Moreover, switching to CPU rendering will probably be slower regardless since your CPU is much slower at the kind of math involved in rendering and the graphics data will most likely still need to pass through the GPU at some point to reach the display.

  2. There’s not just a limit of textures per draw call to worry about. Switching textures bound to slots between draw calls also has a performance cost, which is another reason why some games use spritesheets and/or texture atlases.

  3. Just because spritesheets are better at runtime doesn’t mean you need to author your sprites that way. You can code your game to load the frames individually and stitch them together when your game starts up, or alternatively generate spritesheets from your source textures as part of your game’s CI/CD pipeline (if you have one, I understand many indies do not use them as part of their workflow).

(+2)

If I read point #3 correctly it sounds like there are at least two ways of loading sprite sheets:

1) Load the completed sprite sheets at the very beginning. 

2) Load individual images at first, but then the game patches them together into a sprite sheet. 

Hopefully I got that right! If not I'm sure you or someone else will be quick to correct me. I just recently started to pay attention to the sprite sheet concept in game development. I had downloaded this game on Steam and the art style wasn't to my liking. No biggie, I thought, I'll just find the graphics files and change them out with my own. That's when I saw that all the graphics were consolidated into sprite sheets and that got me to wondering why they are used in the first place.

(1 edit) (+3)

Another amendment.

"quou's" answer is perfect, but it is extremely technical.

The vast majority of game engines and libraries usually resolve these limitations internally, in such a way that as an end user, you will never have these limitations in mint. and you, as a user of these engines, will not have a problem if you use 1000 separate files or if you use a single sprite sheet and although there are performance differences, they are not usually significant in the vast majority of indie developments.

I am not saying that it is not something important, what I am saying is that it depends on each case.

As they already told you, fewer files is usually more optimal, but sometimes it is more comfortable to work with each file separately, in the end it is a matter that depends on many factors, for example, the mugen engine (at least the old one) it asked you that each animation frame of the character be a separate file.

Unity3D has a tool to make it easy to create animations from a sprite-sheet, while another engine doesn't. So in the end it will depend on all these factors if it is better for you to use a separate sprite or a sprite sheet.