Sunday 19 September 2010

How to build a planet

One of the things I've made is a procedurally generated planet based on an geodesic sphere in OpenGL, below I will try and explain how it was made.



In order to create a planet, a sphere composed of multiple triangles must first be formed. To create a uniform distribution and surface area of each triangle forming the whole, a geodesic sphere design was chosen.

Vertices forming the Sphere
The Geodesic Sphere composed of triangles

The creation of the geodesic sphere involved generating two pentagons; one at each pole. The pentagons themselves, which are formed of five triangles, are each extended out from these points till it wraps around the centre of the sphere with more triangles being added per layer.

The number of layers forming the sphere is a compromise between performance and appearance. The larger number of layers allows for more triangles and thus a more complex visualization, however is far more GPU and CPU intense and causes problems on older PC’s.

Though it didn't always look as good as the first video, below is another video showing how it progressed.



It includes several ways of creating the planet, however the one shown in the video uses the process of Perlin noise. As this was done as part of a project I can't realise the source just yet until I strip out all the other un-needed parts.

On another note, where would be a good place just to store code projects? Don't really care much for sourceforge - its over the top if all you want is really a file download site for code.

No comments: