Jump to content

  • Log In with Google      Sign In   
  • Create Account

Techniques for reducing memory usage on HD sprite sheets


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Chrysalis   Members   -  Reputation: 103

Like
0Likes
Like

Posted 15 June 2012 - 07:22 PM

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.

Sponsor:

#2 Sik_the_hedgehog   Crossbones+   -  Reputation: 1757

Like
2Likes
Like

Posted 15 June 2012 - 10:26 PM

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.

#3 clb   Members   -  Reputation: 1781

Like
1Likes
Like

Posted 16 June 2012 - 04:20 AM

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.
Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

#4 Sik_the_hedgehog   Crossbones+   -  Reputation: 1757

Like
0Likes
Like

Posted 16 June 2012 - 10:34 AM

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.

#5 LorenzoGatti   Crossbones+   -  Reputation: 2709

Like
0Likes
Like

Posted 18 June 2012 - 09:26 AM

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.
Produci, consuma, crepa




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS