Jump to content
  • Advertisement
Sign in to follow this  
skow

Streaming textures

This topic is 4915 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a game where I need to be loading textures as the player comes near stuff he has not yet loaded. Each object has several textures and there is about a .7 second pause when loading. As I see it I have a few options, and just want to get opinions on them. Option 1) Every frame read a limited amount of data. I'm not liking this too much because it is dependent on their frame rate. Option 2) Using threads create a new gl context and share the texture information and use a thread to load, this will not stop the game just slow it. Any suggestions or comments?

Share this post


Link to post
Share on other sites
Advertisement
Where is the delay mostly coming from - loading the data off disk or creating a texture with it? You should be able to upload quite a bit of texture data every frame. It's quite possible to copy the whole framebuffer to a texture, mess with it on the CPU, and put it back and still have a 2-digit FPS (I'm so glad I have a card that supports shaders now...). If it's the disk access, you could have a background thread load the image data, and create a few textures every frame. In fact, you could probably just keep everything in system RAM all the time anyway, unless you have a *big* game world.

One important thing is to anticipate texture loading requirements somewhat. The sooner you start loading data before the object is seen, the more you can spread the process out (of course, you'll also get more false hits where the user never actually gets to the object)

Share this post


Link to post
Share on other sites
Another Thing you could do would be dynamically adjust a texture's priority as the player nears/leaves it
that will tell openGL which texes you want in video memory and which ones yuo dont care about as much, (but you can still access and render with cause they are in the openGL runtime system memory instead
)

Share this post


Link to post
Share on other sites
I have a BIG world with far to many textures to keep loaded at once so I will have to have them load/unload as the players move around.

Share this post


Link to post
Share on other sites
Are any of these textures shared between objects?

For example, say two objects that are exactly the same and use the exact same textures, are you giving each object its own texture, or are they sharing them?

Or in other words, are you loading textures that are allready loaded?

Share this post


Link to post
Share on other sites
No textures are only being loaded once for the first instance of an object, I have a textureManager taking care of that.

Share this post


Link to post
Share on other sites
I did that a year ago with OpenGL, the idea was to let the game start and keep the textures loading (texture loading needed 30sec (~150MB, getting compressed to DXT1 1:6 ->~25 MB), rest of the game data needed only 1-2sec). the 2 main problems were (when using threading): you have to allow the other thread to load and select textures (handle stuff) and the other main problem was the incredible amount of lag in the other game-thread! its not like you only get 5fps or something, the engine did still run with around 100fps. the problem is that you get very bad lag when loading lot of small textures (this means you have maybe 20 frames with each 10ms, but then 1 frame with 150ms, then 15 good again, etc.). There is no way to find out when this lags are happening and this was just getting to mad for me and I skipped the whole idea (everything was loaded at startup and worked fine, just little load time when starting the game).

Good luck with your big world ^^

Share this post


Link to post
Share on other sites
I've seen some games where you get only a short loading time at the beginning (2 or 3 seconds) and then you can visit the whole world without waiting anymore.
I can't believe these games do really load everything at sturtup, so they must be doing it at runtime.
How do you think they menaged to do such a thing?
(just think of "Prince of Persia: sands of time" or "warrior within", or even of an older game like "Soul reaver: legacy of Kain")

Share this post


Link to post
Share on other sites
Store the texture twice - once as 16x16 (or whatever minisize),
once with fullsize (2048x2048 :p ).
Now if you enter a new part of the world, start streaming the
big texture (because it can be expected you'll need it soon).

If the textureManager actually gets a request for this texture
(and streaming didn't yet finish), then do an immediate load on
the miniversion...
After the streaming finishes, just let the manager return the big
version and discard the small one (or keep for caching as long
as you have enough place).

Share this post


Link to post
Share on other sites
Quote:
Original post by Kitt3n
Store the texture twice - once as 16x16 (or whatever minisize),
once with fullsize (2048x2048 :p ).

That's a good idea but I already tried it and I can say it's not so easy to get it running completely well.
The problem is that getting the 16*16 texture needs some processing and this takes a load of time. Halving a 8k*4k texture takes alot of time.
This could be improved by having cached thumbnails but this is not always possible.

As for the need to swap textures in/out of server memory, are we sure we really need that? Some issues with this:
1- I hardly believe the driver doesn't have a way to realize this (and it can move bytes much faster than us).
2- It could be a problem to understand when a texture is useful or not.
3- Considering we all have to develop 'the whole thing' are we really sure to make a super-texture-loading-mechanism when we still need a ton of other features?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!