Original Post
Hi,
I''m having some problems getting my terrain streaming to work correctly, every method I''ve tried seems to have sme big negative points, so I''m wondering if anyone can suggest a way to get it working as smoothly as possible?
Basically, I have a buffer of landscape chunks. The buffer is composed of 8x8 chunks. Each chunk is composed of 33x33 vertices (as I''m using splatting following Charles Blooms method). Now, a chunk also contains a 128x128 base texture, a 64x64 alpha map for blending between textures (both of which are 32bit colour).
To stream in my data, I''ve created a worker thread, which I intend to give low priority so it doesn''t disrupt my frames per second too much. Every frame, my render loop checks to see if the player has moved past a streaming boundary. If the player has moved past that point (currently the distance of a single chunk) then it starts to update the chunk buffer. 8 chunks are loaded from disk dependant upon which direction the player has crossed the boundary. The other chunks are simply copied from the existing chunks in memory (no point reloading chunks if they already exist).
Now I''m having problems in 2 areas. Firstly, to avoid the player seeing the whole update take place, I would have to perform the update on a temporary set of chunks, and update the pointer to the chunk buffer, to point to the temporary set of chunks once it is finished. This way, the update is almost instantaneous. My first problem though is that this almost doubles a pretty hefty memory consumption, having to effectively store 2 of every chunk, and I''m really fighting to get this all to run without errors due to being out of memory with only 256 megs RAM.
My second problem is to do with the whole chunk copying process. I''m wondering what is the best method to copy across the chunks? I''ve found that changing the chunk pointers to point to the chunk that will be replacing it, sometimes ends up creating duplicate chunks, and also leaves me with an incorrect set of second texture co-ordinates, as I need these to remain the same so I can map one large texture over the entire terrain. An alternative method, rather thn changing pointers, would be to simply copy across all data stored in the chunk. I''ve managed to do this, but I''m pretty sure that it is going to be far too slow to do. To reliably copy across all data, I''d have to lock 64 index buffers, 64 vertex buffers, 64 alpha textures, 64 base textures... etc etc. But is there another way of copying the information in the chunks, while ensuring that I don''t accidentally end up with duplicate chunks or other data?
Has anyone else faced these problems who might be able to point me in the right direction?
Cheers,
Steve