procedural Planet

The Project

The reason for creating this project was mainly based on BabylonJS. I had used the web rendering engine previously whilst working at CREATE 3D, and thoroughly enjoyed how 3D scenes could be created within a web browser. I wanted to keep the skills that I had learned active, and to do that this project was created.

The procedurally generated planet is based around levels of detail on an icosahedron. After researching how levels of detail can be recursively added to an icosahedron, I began work on this project. However I was not able to immediately work with the inbuilt BabylonJS tools to make the sphere, as the primitive generation of spheres in BabylonJS doesn't share vertices when defining polygons. This means that if I wanted to effect one vertex and have all the surrounding polygons react, I would need to create my own icosahedron generation script, which would share vertices between polygons.

Once the sphere was being generated, other features began to appear, such as terrain height being mapped to a per vertex colouring system, so that high points could be mountains and low points would be sand. Water levels and atmosphere were then added, along with a space backdrop, which uses the same sphere generation techniques but used to simulate a space background with stars.

Goals achieved

  • Implement BabylonJS into a React component to exist on the static portfolio website

  • Generate icosahedrons (icospheres) with vertex and polygon data, which levels of detail could be increased n times

  • Create a mapping system so that a vertex ID could be used to find all neighbouring vertices, which would be needed for algorithms to know surrounding information on the mesh.

  • Implement per vertex functions, which could be ran against the icosphere, where the relational map generated could be used to create interesting terrain on the planet

  • Modified this algorithm to generate atmosphere and space

  • Implemented a per vertex colouring system, where any number of colours can be defined on a scale and a colour gradient can be interpolated from them

Planned Improvements

  • Seeding the random function, so that keywords can be used to generate the same planet each time

  • Adding more functionality to the colouring system, to make different looking planets depending on a value such as temperature

  • A first-person exploration mode, to move around on the surface of the generated planet

Current Progress

The planet generation currently creates aesthetically pleasing planets, however that's about all it can do right now. There's loads of room for extensions with this project, and I will be working away on it in my spare time to improve it with new features.

 
icosahedron generation
The icosahedron pattern found that generates the base sphere which the planet is created from
 
Low poly planet
The planet generation with only 1 level of detail added to the standard icosahedron
 
full planet
Atmosphere is generated from more icosahedrons, but instead of varying height, a function with a hard cutoff is applied to create areas of cloud and areas of no cloud