Unlimited Voxel Terrain threaded geometry generation
by Bill Vee · 01/07/2013 (11:12 am) · 3 comments
This is a little update on some code I worked on over the weekend.
Threading the voxel terrain code has turned out to be a little tricky.
On the server side it is trivial but the client side is a bit more complicated.
The client needs access to the voxel data for collision without having to wait for a thread to release it for accessing on the main thread. And a thread generating geometry to be rendered by the client must make sure the collision and render geometry match.
The solution I have right now is to use two sets of data , one for collision and one for render geometry.
Fortunately because of the way I generate the data for the voxel terrain this turns out to be fairly straight forward. Voxel data is generated from just a simple seed value. As long as a given region has not been changed since it was created then it is guaranteed to be sync with any other data generated with the same seed.
As for regions that have been changed since it was first created , all that is needed is for the process that changed it to notify the other threads of the changes and everything stays in sync.
This approach has lead to a significant increase in terrain generation for rendering.
Right now on my laptop it can crunch a 640 * 640 * 128 region of data and send the render geometry back to the main process in about 4 seconds. The geometry processing thread sends the data back to the main in 32 * 32 * 32 chunks and it sends them back based on distance from the camera.






To keep up to date on my progress follow me on Twitter.
Threading the voxel terrain code has turned out to be a little tricky.
On the server side it is trivial but the client side is a bit more complicated.
The client needs access to the voxel data for collision without having to wait for a thread to release it for accessing on the main thread. And a thread generating geometry to be rendered by the client must make sure the collision and render geometry match.
The solution I have right now is to use two sets of data , one for collision and one for render geometry.
Fortunately because of the way I generate the data for the voxel terrain this turns out to be fairly straight forward. Voxel data is generated from just a simple seed value. As long as a given region has not been changed since it was created then it is guaranteed to be sync with any other data generated with the same seed.
As for regions that have been changed since it was first created , all that is needed is for the process that changed it to notify the other threads of the changes and everything stays in sync.
This approach has lead to a significant increase in terrain generation for rendering.
Right now on my laptop it can crunch a 640 * 640 * 128 region of data and send the render geometry back to the main process in about 4 seconds. The geometry processing thread sends the data back to the main in 32 * 32 * 32 chunks and it sends them back based on distance from the camera.






To keep up to date on my progress follow me on Twitter.
About the author

Torque Owner Kory Imaginism
innovative imaginations