My Dissertation was GPU based generation and rendering of volumetric terrain. The dissertation was based off of the ideas discussed in GPU Gems 3. The project explored the idea of creating a 3D scalar field to describe the terrain and then polygonise that scalar using various algorithms. Due to time constraints I was only able to explore one such algorithm (Marching Cubes) rather than the 3 I had intended (Marching Cubes, Marching Tetrahedra and Naive Surface Nets). The project was created using C++ and OpenGL (spefically the glfw library) and as a result glsl for the shaders.
I broke the project down into 5 stages:
- CPU based implementation of marching cubes
- Shader implementation of marching cubes with a sample flat plane terrain object
- CPU generation of varied terrain for marching cubes
- CPU generation of varied terrain for marching cubes using a noise volume
- GPU generation of varied terrain for marching cubes
In the first stage I simply went through the process of coding the marching cubes algorithm using the GLFW OpenGL library. For the second stage however I migrated this algorithm into a shader to increase the performance of the rendering algorithm.
For the third stage of the project I explored the generation of a 3D texture in which each pixel of the texture contained a float value in the red channel representing the density value at that location, negative density represented air, positive density represented solid matter and locations where the density would be zero would be where vertices would be placed.
For the fourth stage I further explored the CPU generation of the scalar field using small noise volumes to create random, but predictable variations in the terrain. The noise volumes were smaller than the actual terrain volume, allowing the noise to repeat it’s effect throughout the terrain.
Finally in the fifth and final stage of the project I created compute shaders to improve terrain generation, the compute shaders are able to make use of texture sampling, improving the noise volume usage in terrain generation. This also had a knock on effect of improving performance. Whilst I only generated the terrain texture once at program start, using compute shaders I was able to generate multiple large textures very quickly. The largest texture I generated this way was a 500 cubed 3D texture which could then be rendered at high or low resolutions to encompass the detail that the terrain volume provided.