GPU-CPU Octree Terrain
My octree terrain built in Rust, in my own game engine using OpenGL
The terrain in this video is ((2^8)*32)/2 meters wide (~4km) with a chunk size of 32 and LOD_FACTOR of 0.5
Mesher is ran on the CPU, however the voxel generation is ran on a compute shader that is dispatched to the GPU, each frame, for each chunk that needs to be generated.
There is no frustum culling / occlusion culling yet, so this is pretty inefficient , though I am going to implement that soon hopefully.
The density function I've used for this terrain comes from this handy ShaderToy shader that replicates erosion: https://www.shadertoy.com/view/MtGcWh
I use the flat keyword in my OpenGL shader to make it look "low poly", though this is just temporary experimentation.
I've implemented a priority system so the chunks that are visible by the camera are generated first, though as you can see there is a lot of Z-Fighting / Overlapping. This happens because when generating the new chunks, I don't remove the chunks that were at that position, so they overlap.
I'm thinking of just waiting for all the 8 children node in a parent node to finish generating before actually enabling their renderer, that way it will swap the old chunk with the new chunks at the exact frame, and no overlapping will happen.
Thanks for watching.
People & Blogs