Sprite Sheets and Tiled Maps

Few basic questions here. I see a lot of projects store their graphics in a sprite sheet. For an example, a character with say 12 animations will be stored in one .png file. They’ll load it and then cut it up. What’s the benefit of doing this instead of storing each frame in it’s own file? Quicker loading? Better performance on the GPU?

For making a map, say I have a map editor. Would it be better to save out a huge image that represents the map (and then just pan it in game) or manually build it in game up from each individual title?

That is, say you have 32x32 map and each title is 32 pixels. The map size would be 1024x1024 pixels. Should that be stored as one huge image in game, or just manually draw the map from individual titles? For smaller maps, one big image might work, but for larger maps aren’t you likely to choke the GPU?

There’s a bunch of reasons, depending on what your toolchain is and what graphics API you’re using.

  • Loading one image instead of multiple smaller images can often be quicker, as with lots of small files the overhead of opening a file can be significant.
  • Some artists and/or animation tools like to work with a single animation sequence in a single file, or will export to a single file, so it’s just easier from an artist’s point of view.
  • For OpenGL and D3D, putting multiple images into a single texture gives certain performance benifits: you can draw more in one go (because it uses the same texture), and cuts down on the overhead of switching textures.

[quote]For making a map, say I have a map editor. Would it be better to save out a huge image that represents the map (and then just pan it in game) or manually build it in game up from each individual title?
[/quote]
One big image is almost certainly going to require more memory and so be a greater strain graphics-wise. You can reduce that somewhat by slicing it up into metatiles (say, 256x256 images) but it’s still going to be heavy. Drawing the map from individual tiles is a more general purpose and flexible approach, and lets you do more interesting things at runtime (like removing/moving things, having multiple layers that go in front / behind the player, etc.). The one-big-image approach can work (see Baldur’s Gate for particularly impressive results) but generally requires a lot of artist work which most of us don’t have. :slight_smile: