Techniques for reducing memory usage on HD sprite sheets

Started by
3 comments, last by LorenzoGatti 11 years, 10 months ago
This is my first post on here, and I'm posting to hopefully get a solution to my problem.

I have several HD sprite sheets (512 by 512 frames) in a 4096 x 4096 sprite sheet, and I'm having a real heck of a time regarding memory, loading in even one of them to use. The game I am making itself runs at about 16,000 memory usage, according to Windows Task Manager. Loading in one single Character sprite sheet pushes the memory usage of the program to 100K+ memory usage.

I'm aware the size of these is utterly ridiculous but I want to keep things HD, without taking up a whole lot of memory. Are there any techniques anyone here can suggest that'll help me keep the overall quality of the image, but reduce it's impact on memory.
Advertisement
Assuming the texture is uncompressed in VRAM, 4096×4096 at RGBA8 or equivalent (which is 32-bit per pixel) amounts to 64MB. Texture compression can help bring this down (e.g. 16MB, maybe 8MB if you don't mind being limited to on/off alpha only), albeit with some loss in quality, which may or may not be noticeable, depending on the art style.

But yeah, this situation you describe is pretty much the reason why I refuse to use sprites in HD, especially since increasing the screen resolution can easily make their texels big enough to cover over a pixel (with very low resolutions you can at least give an excuse to not provide more detail since it's so low you could argue it's the art style and not just a technical limitation).

You could try splitting them into smaller sprites and combine them when drawing the objects (i.e. make objects out of multiple sprites instead of one). This also has the advantage of potentially being able to get smoother animation out of less sprites, albeit it's hard to do it without it looking robotic (some serious effort will be needed). Alternatively, switching to 2D vector graphics (with texturing, etc.) takes up much less memory as well, and scales up regardless of resolution too. Requires a completely different skillset for the artist, though.

If texture compression doesn't do for you then you'll have to look into alternatives like those two.
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
If your current sprite sheets contain a lot of potentially unrelated sprites, you can try storing the sprites individually in single files (or group together the ones you know that will always be used in tandem), and perform the atlasing dynamically at runtime, when the sprites are about to be rendered.

Another potential way to optimize animations is to subdivide them down into multiple sprites to avoid having to store full animation frames for parts that don't change. E.g. a sprite of a building with a flashing neon sign "Open" could only store the rectangle around the Open sign in the animations, and not the full building, if the other parts of the building sprite don't animate.
Also relevant to the above advice, may want to look how mobile games stored graphics (especially old J2ME ones which were required to fit in a few KB). Not only they tried to fit as many sprites into a single PNG as possible, in some cases they'd split a sprite just for the sake of being able to put its pieces into tighter places. This made more effective use of the sprite sheet. This same technique can easily be applied for HD sprites, the size doesn't matter really.
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

Another potential way to optimize animations is to subdivide them down into multiple sprites to avoid having to store full animation frames for parts that don't change.

In general, you could assemble your sprites from an arbitrary number of pieces that are shared within the same frame and across different animation frames; they don't even need to match a regular tile grid, and you can also assemble semi-transparent pieces on top of each other.
An ideal job for an automated search, but you should take care to avoid using too many colours.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement