• Advertisement

Archived

This topic is now archived and is closed to further replies.

Multiple skyboxes

This topic is 5684 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

Hi DX Gurus, I''m loading multiple skyboxes for my puzzle game. When there is a level change in the game, I present another skybox to the screen. The problem I''m having is that when I turn to level 5 or 6 (5 or 6 different skyboxes loaded), the game slows down a lot. But if I do the "alt-tab" thing (releasing all graphic objects), when I get back to the game everything goes back to normal. The skyboxes use JPGs that combined are about 150KB. Any ideas? PS. Sorry if I didn''t explained right... it''s very late. -- Jose Manuel Guerra jmguerra@guerragames.com GuerraGames

Share this post


Link to post
Share on other sites
Advertisement
A jpeg takes 150Kb on disk. I''m sure you are aware that it''s compressed.

However, when the Jpeg is loaded into memory, it is decompressed and takes 4 bytes per single pixel. That is, a 512x512 texture takes 1 Meg. If you use a skybox, 6 megs per skybox. You load 5 of them 30 megs.

If they were a 1024x1024x1024 skybox, it''s even worst. 4 megs by tex
* 6 = 24 megs by skybox.
* 5 = 120 megs for your 5 levels skyboxes.

Maybe you should think about loading them only when they are needed.

Share this post


Link to post
Share on other sites
quote:
Original post by Coincoin
A jpeg takes 150Kb on disk. I''m sure you are aware that it''s compressed.
...
Maybe you should think about loading them only when they are needed.


Thanks for your response Coincoin,

I already made a test to load them as needed. But in the way I have designed the game, the transition between levels must happen in an instant (as in some versions of Tetris). Loading the textures in gameplay slows the game & will confuse the player.

By reding your post, I see that the size of the texture is prefered as a power of 2, does that optimize the performance significantly?

Is there another format that directx likes better than JPEG?

Thanks,

--
Jose Manuel Guerra
jmguerra@guerragames.com
GuerraGames

Share this post


Link to post
Share on other sites
I don''t think it''s a matter of image format. The problem seems to be in video memory. Obviously, the textures are not being loaded into video memory for some reason, so it''s being rendered directly from system memory into the screen and that''s what make it very slow. When you release the device and restore it again, the system is loading the texture into video memroy and so it becomes fast again. I don''t have any idea how to fix this, but maybe trying to use IDirect3DResource8:reLoad can solve the problem.

Share this post


Link to post
Share on other sites
Sorry, it seems that they system understood the letters as smiley. Anyway, the function name is:
IDirect3DResource8 -> PreLoad

Share this post


Link to post
Share on other sites
quote:
Original post by javaguerra
I already made a test to load them as needed. But in the way I have designed the game, the transition between levels must happen in an instant (as in some versions of Tetris). Loading the textures in gameplay slows the game & will confuse the player.



Just load the new skybox a little before it''s needed, so you only ever have at most 2 loaded at the same time.


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
As the others said, your jpegs might be very small, but when uncompressed into memory..... A skyboxes containint 6 faces of 512x512 at 24 bits for example, can take 6 megabytes, yours might not be as big as 512x512, but if you load 6 into the video memory...

Just try to load em into video memory only when you need em, rest of the time keep em into the system ram.



Looking for a serious game project?
www.xgameproject.com

Share this post


Link to post
Share on other sites
If you dont want the game to slow down, use multiple threads and always keep AT MOST 2 skyboxes in memory.

That way, when you approache the next level, just send a signal to another low priority thread to load the new skybox. This thread will load the image with a very small drop in framerate.

Share this post


Link to post
Share on other sites
quote:
Original post by Dean Harding
[quote]Original post by javaguerra
I already made a test to load them as needed. But in the way I have designed the game, the transition between levels must happen in an instant (as in some versions of Tetris). Loading the textures in gameplay slows the game & will confuse the player.



Just load the new skybox a little before it''s needed, so you only ever have at most 2 loaded at the same time.


codeka.com - Just click it.

Unless I do this with a different thread the loading of the skybox will still be perceived by the user. And I don''t want to learn to do threads on win32 (yet) because I want to keep focused on learning DX.

I made my textures 512x512 and there was a significant performance increase.

I''m did tests using PreLoad, but it worked better using SetPriority to give a higher priority to the textures.

Thanks everyone, the game runs smooth now (expect the release of it soon .

PS. The game''s not a clone.

--
Jose Manuel Guerra
jmguerra@guerragames.com
GuerraGames

Share this post


Link to post
Share on other sites

  • Advertisement