Too many images?
by PeterB · in Torque Game Builder · 11/14/2007 (6:09 pm) · 14 replies
My student has a project with 124 images all at 1024x1024. At inconsistent times it runs very badly and sometimes it runs fine. We've opened different combinations of his level files and cannot find a pattern.
The sprites never move. Everything is completely still, and the whole game involves clicking on sprites. When I say it runs terribly, it's just that the mouse stutters terribly, and crashes when you close Torque.
Deleting all but 46 files definitely helps the performance (but of course the game is missing a lot of content). And the performance is either wonderful or awful, never inbetween. Going from 46 to 47 images will make the difference (sometimes...).
And the levels are often just 2 to 4 images.
I thought about the following approach. Move a number of the datablocks to a separate script file so I can selectively call them before I want to load the appropriate levels.
Or should I be unloading images? I don't know anything about this.
Any thoughts would be helpful :)
The sprites never move. Everything is completely still, and the whole game involves clicking on sprites. When I say it runs terribly, it's just that the mouse stutters terribly, and crashes when you close Torque.
Deleting all but 46 files definitely helps the performance (but of course the game is missing a lot of content). And the performance is either wonderful or awful, never inbetween. Going from 46 to 47 images will make the difference (sometimes...).
And the levels are often just 2 to 4 images.
I thought about the following approach. Move a number of the datablocks to a separate script file so I can selectively call them before I want to load the appropriate levels.
Or should I be unloading images? I don't know anything about this.
Any thoughts would be helpful :)
About the author
#2
Would my method help? To initialize datablocks at periodic times?
And then is there a way to unload datablocks?
11/15/2007 (9:16 am)
That's clear advise. I'll get them to go 512x512, no doubt. Would my method help? To initialize datablocks at periodic times?
And then is there a way to unload datablocks?
#3
I havent messed with em but they sound like what you're needing and you can activate/deactivate them in script.
http://tdn.garagegames.com/wiki/Torque_2D/GenreTutorials/PlatformerLevels
11/19/2007 (8:44 am)
Possibly use packages? I havent messed with em but they sound like what you're needing and you can activate/deactivate them in script.
http://tdn.garagegames.com/wiki/Torque_2D/GenreTutorials/PlatformerLevels
#4
11/19/2007 (9:06 am)
I'm not sure, but i think the engine takes care of loading & unloading images from texture memory as needed.
#5
Only if Preload is deactivated and Unload is activated on the imagemaps.
11/20/2007 (4:44 am)
@Orion ElenzilOnly if Preload is deactivated and Unload is activated on the imagemaps.
#6
On that note, is doing textures as powers of 2 always a good idea?
If I have an image that's 350x350 is it always smart to blow it up to 512x512, assuming 256x256 is too low for some reason.
11/30/2007 (5:02 pm)
Definitely making images be 512 or less in width or height helped exponentially.On that note, is doing textures as powers of 2 always a good idea?
If I have an image that's 350x350 is it always smart to blow it up to 512x512, assuming 256x256 is too low for some reason.
#7
but in TGE, images which are not power-of-two, whether they're for 3D objects or GuiControls,
are padded up to the next power-of-two in each dimension,
so my guess would be that a 350x350 texture is going to consume 512x512 texels.
11/30/2007 (5:07 pm)
I can't be sure about TGB,but in TGE, images which are not power-of-two, whether they're for 3D objects or GuiControls,
are padded up to the next power-of-two in each dimension,
so my guess would be that a 350x350 texture is going to consume 512x512 texels.
#8
11/30/2007 (7:51 pm)
From a quick look at the sources it would seem to be the same deal in TGB.
#9
11/30/2007 (8:21 pm)
So the only other note on that is I often find my sprites show a faint white line (on an edge) when they or the camera is moving about. Sizing the file to a power of 2 always fixes it.
#10
12/01/2007 (10:35 am)
I have some images with a faint white line as well. I was going to recreate the images. I will be sure to make them a power of 2.
#11
common\preferences\defaultPrefs.cs
You will see a variable called $pref::T2D::imageMapShowPacking. Change it's value to one and you get the packing information in your console log. This will show you what images are being sized up and to what dimensions.
Be advised, you shouldn't just make your images a power-of-two, you should make them a power-of-two - 2. So in your case 1022*1022 or 510*510. With multi-frame images it works the same for frames. So an animates sprite of 2 frames, each 510*510 px should result in an imagemap of 1020*510. Not 1022 or 1024.
Again, use the packing information to your adventage
02/05/2008 (3:37 am)
TGB pads the images to the next power-of-two. When you browse to:common\preferences\defaultPrefs.cs
You will see a variable called $pref::T2D::imageMapShowPacking. Change it's value to one and you get the packing information in your console log. This will show you what images are being sized up and to what dimensions.
Be advised, you shouldn't just make your images a power-of-two, you should make them a power-of-two - 2. So in your case 1022*1022 or 510*510. With multi-frame images it works the same for frames. So an animates sprite of 2 frames, each 510*510 px should result in an imagemap of 1020*510. Not 1022 or 1024.
Again, use the packing information to your adventage
#12
Can you please explain why we should do that? Not the power of 2 but the minus 2.
02/05/2008 (4:59 am)
Quote:you should make them a power-of-two - 2.
Can you please explain why we should do that? Not the power of 2 but the minus 2.
#13
I often make my images 250x250, so I can split it into cells of say 10x25, or 50x50, or just 4 frames of 125x125. Then with filter pad turned on the image is padded up to 252x252 - which finally gets rounded up to 256x256, so there's very little wasted space. This is just so that I can work with my 10x10 grid in photoshop. For maximum texture efficiency you should make your image 254x254, particularly if it's not split into smaller cells.
If you are sure that your texture won't need to be filtered, then you can make it the full 256x256.
02/08/2008 (11:31 pm)
If you make your image 256x256 and turn on 'filter pad' - which you will usually have to turn on, if you image is split into cells that have transparent edges, then Torque pads out that image by 1 pixel on every side to prevent filter errors (lines appearing at the edge of the image due to filtering across to the other side of the image), making it 258x258, which has to be rounded up to the next power of 2, so your image ends up using 512x512 pixels in video memory.I often make my images 250x250, so I can split it into cells of say 10x25, or 50x50, or just 4 frames of 125x125. Then with filter pad turned on the image is padded up to 252x252 - which finally gets rounded up to 256x256, so there's very little wasted space. This is just so that I can work with my 10x10 grid in photoshop. For maximum texture efficiency you should make your image 254x254, particularly if it's not split into smaller cells.
If you are sure that your texture won't need to be filtered, then you can make it the full 256x256.
#14
02/09/2008 (12:46 am)
Thanks for the detailed explaination Conor. I learned something new.
Chaim Krause
Chaim Gang
How much memory does your video card have? Even 512MB can't hold all those. 46 images = 192937984 bytes & 47 = 197132288 bytes. That comes close to 192MB + 64MB = 256 MB. I would guess you have 256MB video RAM and 64MB is used for non-TGB stuff.
Just a WAG though.