Planet generation

Author: Basilicous | Date: 01/05/22

During my experiments with planet generation, I encountered a few problems and wanted to share my project, which is why this exists.
So, traditionally game engines like Godot construct a sphere called a 'UV sphere', this is done by connecting circular segments which gradually decrease in size towards the poles. However, there is a problem. With this method, the majority of the vertices become concentrated at the poles, leaving an uneven point distribution.

You can see the vertices 'bunch up' towards the poles here.

Unfortunately this renders a UV sphere unsuitable for terrain generation due to uneven point distribution. So how can this be fixed? Well, if we take a Platonic solid, like a cube

All 5 platonic solids.

Next, we must subdivide each side on the platonic solid. This is done by repeatedly adding vertices to the midpoints on every triangle on the shape. Adding more triangles effectively increases the shape's resolution.

Then we normalise the vertices on each side (reduce the lengths of the vectors storing vertex data on each side to 1 by dividing each component of the vector by the length/magnitude of the vector)

Demonstration of this process in 3d.

Demonstration of this process in 2d.

Now we should be left with a sphere, with (somewhat) even point generation. The next part of this process is fortunately the simplest, by simply overlaying noise to each vertice (during the mesh generation), we can recieve quite good results.