Save Vram Memory ,Cut your sprites up

Post your own tutorials, guides and demos.

Post » Tue Nov 16, 2010 11:00 pm

This has probably been done before,But here is an example of how to optimise your Vram By cutting those big sprites into tiles.The 1st screen is the optimised sprite and the second is the full big ass sprite.
And the best program for cutting big textures into smaller ones can be found here http://www.photoscape.org

[url:3suy7w08]http://dl.dropbox.com/u/7658043/MemorySaverExample.cap[/url:3suy7w08]
B
22
S
3
G
6
Posts: 1,356
Reputation: 7,141

Post » Wed Nov 17, 2010 12:37 am

Its a good example, but for the "big picture" you should compare power of two textures, and frame rate.... there's always a trade off.
For even more optimization check out the tiled background object with P^2, and non P^2 versus frame rate, and ram of your images.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Nov 17, 2010 8:21 am

I wonder if it's really important to reduce the vram usage on a 2d games... with the equivalent of 10 1024 textures, you're using like 30 mb of video memory. Is this so important to save several mb of vram ?
B
72
S
15
G
4
Posts: 311
Reputation: 11,609

Post » Wed Nov 17, 2010 9:08 am

Yes, especially when you start adding animations, shaders etc. it can really add up.
You have to take into account your target audience as well.
Basically the less vram/ better frame rate you have the more systems there are that can run it.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Nov 17, 2010 12:05 pm

[quote="newt":3q22ax80]Its a good example...[/quote:3q22ax80]
No, it is not. I thought, I made the problem clear when I was posting in this thread, but I will explain it once again.

The slicing that was done here is just replacing one memory-waste-sprite with 36 not-so-obvious-memory-waste-sprites. The original image was 700x700, which totals 1960000 bytes (1.87 MB). On most graphic cards the resulting sprite will consume the next power-of-two size, which is 1024x1024 and totals 4194394 bytes (4 MB).

So, why is this example not a good one? Is does save memory, doesn't it? Yes, it does, but by chance.
1) The arranging of the 36 sprites was done wrong. The slices are of 4 different sizes: 116x116, 116x117, 117x116, 117x117. This was not taken into account and the sprites arranged on a 116 grid, leading to an image of the size 696x696, thus losing image information.
2) The slices created are of a non-power-of-two-size and also waste memory. All the 36 slices will consume the next power-of-two-size, which is 128x128 in this case. If the original image would have been splitted into 49 or even 64 pieces, the resulting memory use would have been the exact same. If it would have been splitted into 25 pieces, it would even use 256x256 per piece. Just because it wasn't splitted into power-of-two-sizes.

I remade the example to show, that you can reduce the (texture) memory usage to exactly the size, that the original image consumes:


I won't comment on the "do we need to save memory"-issue. But, if you decide to split up your images, then do it consequently. Always split them into pieces of power-of-two-sizes (the magic of power-of-two is that you can represent any number!)

Here's the cap: [url:3q22ax80]http://www.mediafire.com/file/qec45byuwxb0q29/BetterExample2.cap[/url:3q22ax80]
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Wed Nov 17, 2010 12:58 pm

Thanks tulamide for showing us the Correct way of conserving memory.How did they conserve memory back in the days of the good old sega Genesis or Snes?.I mean look at earth worm jim for instance that game was only 3.00 Megabytes big.Yes they reduced the colors and sprite size to keep everything to a minimum but it was still amazing how they worked with so little and still created games which looked and played fantastically.
B
22
S
3
G
6
Posts: 1,356
Reputation: 7,141

Post » Wed Nov 17, 2010 2:32 pm

Imagine an image of a circle. There's a lot of wasted space in the corners, right? They would often stuff those wasted spaces with other stuff and reassemble it all every frame.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Sun Nov 21, 2010 9:07 pm

[quote="DravenX":3gavfl8w]Thanks tulamide for showing us the Correct way of conserving memory.How did they conserve memory back in the days of the good old sega Genesis or Snes?.I mean look at earth worm jim for instance that game was only 3.00 Megabytes big.Yes they reduced the colors and sprite size to keep everything to a minimum but it was still amazing how they worked with so little and still created games which looked and played fantastically.[/quote:3gavfl8w]
Well 3 megabytes is A LOT.
On nowadays PC we have become used to wasting memory space away (Standard PC nowadays have several gigabytes of ram!), but back in the time you could store several games in 3 megabytes. It just a matter of knowing how to work with restrictions.
At the time of 8 bit computers, 64 kilobytes was reserved for big games. They could still cram very large levels in that space.
B
3
S
1
G
3
Posts: 45
Reputation: 1,140

Post » Mon Dec 06, 2010 8:22 am

hmmm, hi guys. i have read the whole topic and the one corresponding with the issue (VRAM & Pow 2 Textures) and i know that cutting images IF properly is good. but i have a problem...
you see - i can image cuting the tiles of a static image.
but what about animation? especialy a huge one.
i am asking because here i have a very nice looking animation. but i also have two problems.
first: it has 1521 x 435 resolution
secund: it has 106 frames

now how i am supposed two cut that, left alone arranging on screen...?
this animation alone eats 200MB+ of VRAM, and he whole aplication eats 500MB+... quite huge numbers for a Layout with just 3 pictures, where 2 of them are static.

and yes, it has to be that big, and yes it must have 106 frames.
ImageImageImageImage
B
26
S
7
G
7
Posts: 572
Reputation: 6,097

Post » Mon Dec 06, 2010 9:58 am

Sorry, but that's way, way, way, way.... way out of the realms of whats possible.
What your describing is more like a cut scene, than an animation.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Next

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests