Sign in to follow this  
kdworld

Texture loading , some thoughts

Recommended Posts

Hello Friends, Currently I am working on portal engine. As we know portals are used for hidden surface removal. My engine needs to support textures.. But if I load all used textures at startup it will be a memory greedy engine. I don't want that, then i thought about loading at run time , it means i will load the texture when the corresponding triangles are going to visible. Ok it is good when the texture size is small.. Otherwise i guess it will cause to occur some delay during gameplay.. So anyone knows any good way to handle this problem ? any existing solutions ? Thanks in advance ^_^ KD

Share this post


Link to post
Share on other sites
Here's my two cents:

How about loading them beforehand but keeping them compressed in the RAM? When you would like to use them, you can just decompress them and bind. Then free the decompressed memory when you're done.

Share this post


Link to post
Share on other sites
One thing you can do to reduce the memory overhead is to load all the textures, but only load the bottom few mipmaps of each of them. This is a big saving because the top mipmap level accounts for 75% of the data in a texture.

During gameplay you then load the more detailed textures for things that need them on another thread, and use them in place of the low detail ones when they are available. Ideally you would also look ahead a bit, and load what you will need 'soon' as well so the player doesn't see the switchover. Don't forget to unload the big textures that the player can no longer see as well.

However, before you go to all that trouble make sure you compress your textures with DXT1 (or DXT5 if they have an alpha channel). That will cut them down to 1/8th (1/4 for DXT5) of the uncompressed size. It will also make the game run quicker as it saves on memory bandwidth on the graphics card.

Share this post


Link to post
Share on other sites
I'd suggest loading them all at once. You'd be surprised how many textures you can load for very little RAM. If you creating a level-based game there is virtually no reason not to have all textures loaded at once. Not to mention, RAM is cheap these days. Every decent PC has 1 Gig at least, 2 Gigs preferably if they have Vista, since Vista itself consumes a Gig. =(

Unless of course you are coding a "seamless world" engine. In that case, good luck. It is very hard to do. =)

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