Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am embarking on a massive (image quality, file size, high frame count) project. I am still working on the basic engine, but have a big question that I would like answered before I begin testing. (It requires a lot of work to test, and possibly fail and have to recreate all sprite sheets, so an answer can help me save weeks of work if I'm wrong.)

The game is entirely in 2D, with 2.5D view. I want to eventually have 40 animations, which all have to be animated in 8 directions. I want each direction/animation to have its own sprite sheet. This equates to hundreds of spritesheets and thousands of files.

Before the obvious solution "Degrade quality for file size!" I would like to take every step possible to prevent degradation of quality, animation frame count, and image size.

Before my solution, one character was 350MB in ram (LOL!) but that was fixed quickly down to 10-20MB per whole character. That is...if I were to load ALL (40) animations in ALL directions (8). So if I were to load 320 sprite sheets into memory, it was going to be a ridiculously large amount per character in ram.

MY QUESTION IS THIS:

How much (of total sprite sheets) should I have loaded into memory at any given point?

Can I get away with loading ONLY the CURRENT spritesheet (Direction + Animation) into memory? Is modern hardware fast enough to constantly swap textures on the fly?

Players could, at any moment, change direction. This would change the entire spritesheet. Same for animation. So within a split second, the game would have to load a specific new spritesheet, unload the old one (or unload it eventually), and render all within a split second. This would have to be done once for every character, anytime they animate or change directions in a real time game.

Fortunately, the amount of characters on screen at once will be limited by the fact the game is 2D, but I'd prefer to be able to cram in the maximum amount without performance issues on a mediocre computer.

Is texture swapping, file loading, instant rendering from HDD and memory-- all so fast with modern hardware that I wont even need to worry about ANY of this?

I just dont want to work on all of these spritesheets (from thousands of images I already have) only to find out my performance will be horrible and have to redo all spritesheets. Even to test, since I have a layering equipment system, is a time consuming task for spritesheet creation. That is, until I find a solution to process those faster (automation, i do it manually currently, using a program)

share|improve this question
3  
You're talking about using gigs of ram to hold the animations of one 2D character? Yes your performance will be horrible. Even a modern bleeding edge computer is going to choke. I'm not sure what the point is either, you're going to be loading pixel information for far more pixels than a user could even display. Why load 10,000 pixels for a sprite that is only going to be displayed on 50 pixels of screen space? Beyond that, this question is overly broad and depends on far too many variables to be accurately answered. – Byte56 Apr 30 '12 at 17:39
If you really wanted to go hog wild with it you can look into sparse virtual texturing (sometimes also called megatexturing) silverspaceship.com/src/svt But it's likely that you don't need to go that far. – Tetrad Apr 30 '12 at 20:05
No, I am NOT talking about using gigs of ram to hold aniamtions of one 2D character. I am talking about what created my concern (gigs of ram) before finding a possible solution (cutting it down to only 10-20MB per whole character) but with it comes some drawbacks (depending on how fast computations can calculate spritesheet creation). My first question is in a 2D game, such as Diablo 2 or Baldurs Gate 2, or a 2D or 2.5D game, how many spritesheets or animations are typically loaded into memory per character? All of them? Only the current? Only a few (Current + Last few)? – user15858 May 1 '12 at 2:27
Have you tried severing your character's head, arms, body, legs into individual parts? Individual parts will pack tighter into spritesheets and may allow sharing of parts over animations. – 5ound May 1 '12 at 6:39
If it takes so much to test it, you are likely doing the wrong test. – Lohoris May 1 '12 at 9:54
show 3 more comments

4 Answers

up vote 0 down vote accepted

Consider making the graphics quality configurable in the game. For example you could set a target for the "high end" of hardware you want your game to work on, and design your graphics and animations around that target. Then provide graphics quality settings that let you, say, use 50% scaled versions of the sprites, or use every other frame of animation.

share|improve this answer

Swapping textures will kill your performance. Modern hardware has only gotten more susceptible to this problem, not less, as the speed and power of the shader units and video RAM are growing much faster than the speed increases of the bus between system RAM and the GPU.

The only sane approach is to cut down your texture sizes, or generate procedural sprites (using vector art). As another reply stated, there is absolutely zero reason to have huge textures for sprites that will only be a few dozen pixels tall on the output. It sounds like you're looking for a solution to a problem that you're imposing on yourself for no reason.

Also, you will usually have better looking art if you design for the target pixel size than if you downscale a high-res texture.

share|improve this answer
3  
Indeed - "It sounds like you're looking for a solution to a problem that you're imposing on yourself for no reason" – Byte56 May 1 '12 at 1:20
"As another reply stated, there is absolutely zero reason to have huge textures for sprites that will only be a few dozen pixels tall on the output." Zero reason to have spritesheets as opposed to tiny single images? This is contrary to what I read on here about spritesheets vs single images. (Always load a huge image than to load a lot of tiny ones). – user15858 May 1 '12 at 2:29
Any "problem" I impose on myself is obviously for a reason, such as a game feature or quality. If there was no reason, there wouldn't be a problem lol. – user15858 May 1 '12 at 3:31
2  
Older games didn't use OpenGL or modern D3D, didn't store textures in VRAM, and were basically just accelerated blitting engines; this is not at all how modern hardware works. The acceleration methods used by old games are literally not even in new hardware anymore. Your question was whether there's be a performance hit doing things the way you describe - the answer is yes, a big one. Also rememer that modern GPUs do allow compressed textures, which can help a lot. Look into trying DDS textures instead of JPGs (no game uses JPGs - worst possible texture format for a game). – Sean Middleditch May 6 '12 at 19:08
1  
"It works" proves nothing. Swapping textures means transferring things over the bus. This is slow; you're just lucky and not stressing it much; common for little hobbyist games. Doing this in general is bad juju, and that is plain fact. Modern hardware is plenty "powerful", so longed as it's not abused too hard. You're only abusing it a little. :) and yes, disk transfer is a major problem, disk is much slower than anything else; finding the balance between disk and runtime speeds is part of what we get paid to do. – Sean Middleditch Jan 28 at 22:10
show 15 more comments

You need to prototype this, with placeholder data.

Create a simple program that outputs a sprite sheet where each frame consists of text describing what it should be (e.g. "Sprite 7 frame 5"). Use that to create the final number of sprite sheets you're going to end up with, and see how well that runs a test scene with everything loaded into memory.

If it runs ok on your target hardware then go ahead and create your sprites, otherwise you'll need to adjust your plans or optimize the code to make it work.

share|improve this answer
Thanks, that sounds like the best idea. – user15858 May 1 '12 at 2:25

The answer was actually quite simple: PNG QUANT.

By using PNG QUANT, I turned a spritesheet that would be MB's into KB's. It would shrink the file size dramatically.

The loss in quality? Next to nothing. Especially if I kept it at 256 colors. 32 colors looked perfectly fine too, but had a SLIGHT bit more loss and less of a impact on file size. (Still worth it if you need to squeeze every drop of filesize though!)

Even a JPG is bigger than a PNG-8 from PNG QUANT.

Ex. I turned a 711 kb sprite sheet into a 192kb sheet (27% the size of original). I turned a 6.73MB sprite sheet into 1.82MB (27% the size).

I also decided it wasn't necessary to use 8 directions, when 3 of them can be duplicated. I now just have North, South, East, Northeast, and Southeast. All the west directions are flipped versions of E/NE/SE. If I want to make it look better, it's still less consuming to simply add an ADDITIONAL sprite and all its sheets in the other hand to prevent Left hand from becoming RIGHT hand. Even if I duplicated all hand-held sprite items, it's still a bigger savings than having those 3 extra directions for EVERYTHING. I'd probably do this ANYWAY since I want dual wielding in my game.

5 Directions Isometric. TEXTURE PACKER to pack all the images into a sprite sheet. PNG Quant everything to 256 colors (32 colors if I want to squeeze the space).

I also am changing my game from a RPG/MMORPG with 40 races + Equipment, to a game with 0 equipment and instead 400+ characters. A single race's equipment of about 50 items would equate to a ridiculous amount of GB's on the harddrive. A single non-equipable character is about 32MB. So by having 400+ premade characters without equipment it's about 2GB. To have 2 races (human male, human female) with about 100 equipable items is about 6GB. 64MB for the models, and about 6GB for the items.

So I'm taking away equipment, for something closer to RAGNAROK ONLINE or LEAGUE OF LEGENDS. Equipment is overrated anyways. This translates my game from about 20GB (png quanted 40 races + equipment) to about 2GB (400+ character models already equipped to choose from).

share|improve this answer
Er, that's 32MB per character BEFORE png quant, and at their original massive size. Funny, everyone was wrong :) With PNG Quant, flipping directions (eliminating 3 West directions, and eliminating equipment but drastically increasing "races/classes" I can have incredibly massive sprites with insane quality if I wanted. I can't express enough how even turning high detail PNG's into PNG-8 (256) with PNG Quant, the loss is extremely small to almost non-existent with some images. – user15858 May 24 '12 at 17:49
2  
If you're using compressed textures in GPU RAM I'm pretty sure on-disk size has no correlation to in-memory size. – Tetrad May 24 '12 at 18:14
Even if you're not there's often very little correlation. – mh01 May 25 '12 at 1:24
The answer was that yes, modern hardware IS fast enough to rapidly swap tons of big textures hundreds of times per second. The only problem I ran into was the HDD space, which PNG quant helped with. Unfortunately, it didn't help enough to justify what would be a very, very large game on the HDD. So instead, I cut out equipment in replace of something closer to slightly customizable character classes / hero types (more like pre-determined heroes with variant skins like League of Legends or RTS game characters, and less thousands of equipable items which is typical in 3D rpg games.) – user15858 Jan 22 at 0:58
It will kill performance. – Dave Jan 22 at 4:42
show 1 more comment

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.