Sign in to follow this  
Mushu

Loading textures in a sprite-based game... but faster...

Recommended Posts

Hey guys! I'm making a sprite-based RPG game. Problem is, each unit has about 3 states, each with (on average) 7 frames of animation. Since I'm stealing the art of Reiner's tilesets, I've created a sprite loading system so that I can import all his stuff really easy. The only problem which comes along is the INSANE LOAD TIME OF LOADING 100+ 128x128 textures. I'm thinking of converting all of them from .bmp to .jpg to speed this up, then dynamically loading them as necessary (instead of all at once). I'm not sure how much this will improve preformance... but it should do *something*. Is there anything else I can do (without having to modify each of the hundreds of images) to speed this up? Or should I take my own advice and "make a pretty loading screen to stare at"? :P

Share this post


Link to post
Share on other sites
Quote:
Original post by Mushu
The only problem which comes along is the INSANE LOAD TIME OF LOADING 100+ 128x128 textures.

They shouldn't be talking a long time.
- How long does it take?
- What kind of HD you've tested this on?

Share this post


Link to post
Share on other sites
Hmmm... shouldn't be that bad. I load 100's of 128x128 sprites in some of my games, and they rarely take more than a few seconds... but it is noticeable.

I assume they are A8R8G8B8 format? Maybe some tips...

1) I believe it helps convert to a format with compression (use ".dds" format or compressed .tga" if at all possible). I believe compression helps load times at the very least by preventing swapping to the disk when it runs out of memory.
2) Yes, convert to a 16-bit format if you cannot notice the difference in quality. You will find this to be the case with some of your sprites or textures.
3) If your files have an alpha channel, see if they can be simplified. For instance, if your alpha channel is only black/white switch it to a single bit.

Share this post


Link to post
Share on other sites
Something to keep in mind (from the d3d performance optimization tips):

Quote:
Use square textures whenever possible. Textures whose dimensions are 256x256 are the fastest. If your application uses four 128x128 textures, for example, try to ensure that they use the same palette and place them all into one 256x256 texture. This technique also reduces the amount of texture swapping.


if your game is more serious than just a hobby thing you might want to consider recomposing the textures. I dont imagine it would be too hard to write a small d3d app which loads 128x128 textures and renders them to a 256x256 texture file.

Share this post


Link to post
Share on other sites
This might be beyond your capabilities, but the 'ideal' would be to have a seperate thread load all of the textures into memory while your game sits at the entry menu.

Assuming you actually need all of them at one time, which you may or may not. If you don't, then loading each unit [3x7x128x128x4=~1.5meg ?] as needed should be only slightly lengthy.

Share this post


Link to post
Share on other sites
Quote:
Original post by dhanji
Something to keep in mind (from the d3d performance optimization tips):

Quote:
Use square textures whenever possible. Textures whose dimensions are 256x256 are the fastest. If your application uses four 128x128 textures, for example, try to ensure that they use the same palette and place them all into one 256x256 texture. This technique also reduces the amount of texture swapping.


if your game is more serious than just a hobby thing you might want to consider recomposing the textures. I dont imagine it would be too hard to write a small d3d app which loads 128x128 textures and renders them to a 256x256 texture file.

I'd even use 512x512 textures.
Only really old cards can't handle that and even in that case d3d takes care of that.

Share this post


Link to post
Share on other sites
Quote:
I'd even use 512x512 textures.
Only really old cards can't handle that and even in that case d3d takes care of that.


I totally agree it's wise on a 2D game. But Ive noticed on my radeon 9000 that a 512x512 texture wrapped across irregular geometry drops my fps compared to 4 256x256 textures at the same coords. It's only like 1-3 fps but...

Anyone have this experience?

Share this post


Link to post
Share on other sites
Quote:
Original post by dhanji
Quote:
I'd even use 512x512 textures.
Only really old cards can't handle that and even in that case d3d takes care of that.


I totally agree it's wise on a 2D game. But Ive noticed on my radeon 9000 that a 512x512 texture wrapped across irregular geometry drops my fps compared to 4 256x256 textures at the same coords. It's only like 1-3 fps but...

Anyone have this experience?

The bold part is the important one. Though four 256x256 resemble one 512x512 texture, filtering doesn't need to be performed to the same extend for each individual texture as for one bigger texture.
The Radeon 9000 sure needs a tiny (1-3 fps isn't even noticable if your framerate is above 20) bit more time to perform filtering, I guess.

I could be completely wrong, though.
Pat

Share this post


Link to post
Share on other sites
I always create a resource file with all data packed into it and zipped using a free compression library. So there is one resouce file per level rather than lots of smaller data files. You need to create a support library for extracting files and adding files etc. but it's worth it in the long run.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this