To ensure the creation of river systems and relief details I use a combination of several numerical layers (or surfaces). These layers are defined on a regular lattice on the sphere. So it was already in the project earlier, but now the number of layers has become more, and in the future their number will be potentially infinite. In this post we will take a closer look at these layers and begin the description of how they are built.

## The global grid of heights

The base layer, or *global grid of heights*, values of which are calculated on the planetary sphere global lattice, determines the outlines of the continents and the elevations of the planetary relief in a first approximation. It is in turn a combination (sum or product) of several other layers. Each of the combined layers can be either the result of the construction of fBm process surface, or some other predetermined layer. So, for example, by making the product of fBm surface with a layer in which some points have value of 1, and others have value of 0 we can create planets like planet Mandelbrot.

In addition, we can apply transformation functions to each layer as well as to the resulting global grid of heights. The latter case refers to the so-called *Eartherization* process for the relief, that is a transformation of the continental relief in such a way that the elevation distribution function on the occupied territory can be close to the exponent.

Combining numerical layers is very similar to how image layers are combined in graphical editors. In the figures below, for a simple example, the first two images are combined by pixel multiplication into the resulting third image. This can be interpreted as a combination of the island’s area in the first image with a hill in the second image into the resulting image of the island with the hill.

At the moment, the project has implementation for the combination of only two such layers. When creating relief details similar to mountain ranges and, perhaps, some absolutely fantastic relief features, more layers will be required.

In further posts we will no longer deal with the issues concerning building the global grid of heights, but we proceed to the next new and more complex topic.

## The grid of heights in rhombs*

This grid is built inside rhombs covering the entire sphere. For myself I call it *local heights grid*. In general, the fact that the relief is built separately in each rhomb is a blessing and, at the same time, a curse of the project. A single rhomb contains only small data and, as a rule, it is necessary to simultaneously store in memory only several rhombs data, and not the data of the entire planet. On the other hand, there are a lot of problems when aligning the relief in neighboring rhombs. The method described in next posts serves to overcome the unwanted relief details that arise on the borders of rhombs.

The local heights grid is a combination of the values of some functions defined on the points inside each rhomb. Further, these values are added with an averaged value obtained from the global grid of heights. That is, the final planetary relief is the sum of the global and local grids.

For each individual point in a rhomb we calculate some averaged value of the heights from the global grid (first figure above). As it turns out, it cannot be limited to the simple weighted average value from the surrounding nodes of the global grid, otherwise the borders of rhombs will be too noticeable. We will need a rather complicated method for calculating these averaged values. And these averaged values can be called *the base heights*; in the aggregate they form *the base heights surface*.

The values of the local heights grid (second figure) are simply added to the base heights (third figure). They are a result of the fBm process, which is altered by a special function in order to obtain river valleys and mountains. The values of the local heights grid may be negative. For the planet Serpento I deliberately allowed large negative local grid values, which led to the strange lakes described in the previous post. This was done in order to better retouch insufficient smoothing of the base heights surface, and it also helps to make the coastline more natural.

*I prefer to avoid the long words ‘rhombus’ and `diamond` in favor of a shorter ‘rhomb’ (similar to the Russian ‘ромб’)

To be continued..