Random_genesis

- Simple 2D planet generation

The objective is to design a system capable of generating sprites representing many different types of planets.
Since I will not be focusing on the features of a planet's surface, but rather on its general appearance, the generation will remain relatively lightweight.

I will be using Processing 3, which offers an array of very straightforward tools for generating and manipulating textures and images.


"Earth-like" (Aug 2018)

Since the generation of different classes of planets will be implemented separately, I will start from "Earth-like" planets, which seem to be intuitively simpler, while offering challenges and problems that will be common to all classes.

In actual astronomy, "terrestrial planets" are composed primarily of silicates and metals. Of course, not all these planets develop life of any kind, have oceans or even have an atmosphere.
A good starting point though, is a planet with a complete set of features: solid ground, some kind of ocean, life (vegetation), and some kind of atmosphere.
It will be comparatively easier to remove any of these features later.

The plan is to generate a texture first, and then make it look like a planet. The texture will have to show different layers: at least one for the ground, one for the oceans, and one for the clouds.
In order to keep everything light and simple, I will just be using matrices of Perlin noise (natively offered by Processing) to define where layers are visible and their specific looks.
One matrix of noise will define the "altitude" of the ground, distinguishing landmasses from oceans.
One layer will define the color of the land, and one will define the color of the sea.
An other two will be necessary for the clouds. Initially I wanted to only use one, but the properties of Perlin noise make it so that the values are strongly squashed towards the mean, making it very difficult to manipulate the amount of clouds that are visible. Instead, two layers will be used: one definig where clouds are, and one defining how they look.

This would mean only generating 4 matrices of noise in order to get a "full" planet texture, plus the iterations necessary to render it.


A first layer of Perlin noise defines landmasses: the values generated are in the range [0,1], distributed as a very narrow Gaussian Bell curve. Values greater than a given sea level (in this case 0.5) are flagged as land (in white), while the rest will be oceans.


Two more layers define the colouring of land and sea: the noise value is used as parameter for a linear interpolation between two "extreme" RGB colors.
For now "standard" colors are being used. Some degree of randomisation will be introduced later.


A mask defining where clouds are going to be visible is generated using the same approach: noise values greater than a certain threshold define pixels where clouds will be drawn (in red in the image).


Clouds are drawn in these areas using yet an other layer of Perlin noise.
The noise value is used to interpolate between the underlying colour (land or sea) and whatever colour the clouds are going to be.
In this case, white.

This kind of texture is very simple yet acceptable for the moment. The next step is to make it look like planet.
Rather than applying the texture to a real 3D item, the spherical shape of a planet is simulated by applying a precomputed shadow.
The shadow of a sphere was initially drawn using the sphere() primitive, with 3D lighting, on a blank image. Then the image is exported and saved as a jpg. At launch, the generator loads the picture of the sphere, draws it, and stores its pixels as an array of colors.
Once the planet surface is generated an other interpolation is performed on its pixels using those from the sphere as parameter, where darkness is applied to the colors producing the illusion of a 3D object.

Here are shown some of the planets produced. The variety in the output is not sufficient, but will greatly increase once the parameters for the generator become randomized.