Planet Generator

Existing random planet generators usually take a top-down approach to designing geological features. But terrestrial planets and real-world features develop from simple laws carried out by nature. Emergent complexity. Tectonic plates shift and subduct, creating continents, mountain ranges, and seabeds. Oceans and mountains determine air currents and weather patterns, which in turn determine climates. From a single orbital photograph of earth, all of this is laid bare.

screenshot

Planetgen is my personal undertaking of emergent complexity applied to the generation of simulated terrestrial planets. While currently incomplete, it features randomly generated tectonic plates with faultlines on a subdivided icosahedron model with variable level of detail. Because it’s developed in TypeScript, it can be run in any browser with WebGL support.

screenshot

At the lowest level of detail (LOD), a planet is generated as an icosahedron and faultlines are randomly created between faces. Tectonic plates are assigned to the vertices as divided by the faultlines. As the planet is subdivided, more detail is added, but the initial overall plate structure is preserved.

Try adjusting the LOD slider on the live demo hosted on my site!

Sample code from planet.ts

protected _updateLOD(LODLevel: number): void {
  // generate each new LOD up to LODLevel from the last LODLevel
  // starting at LOD.length
  for (let i = this._LOD.length; i <= LODLevel; ++i) {
    this._LOD.push(
      new TectonicLOD(
        this._points,
        this.radius,
        this._rng,
        this.nodeDensity,
        (this._LOD.length > 0) ? this._LOD[i - 1] : null
      )
    );
  }
}

When generating the planet for a specified level of detail LODLevel, we iterate through each LOD starting at 0 (which is an icosahedron), passing the previous LOD object to the constructor, so that each new LOD is generated by subdividing the one immediately preceding it. Every level of detail generated is then stored in the array this._LOD to be retrieved from memory to display as appropriate.

Source code is available here.