All posts by mamont

More realistic rivers

Looking at the rivers from the previous post it seems that everything is quite pretty. But perhaps, like me, you feel that something is wrong. Oh ye, there are no such pretty smooth rivers in nature!

Let’s open google or other Earth maps and look at the shape of any river banks. Usually, the width of a river does not remain constant and gradually changes, even when the amount of water in it is invariably. Furthermore, the banks do not vary simultaneously. This, as well as the fact that such behavior of the banks does not depends on the width of the river, suggests that the shape of the river is a fractal (do not confuse this fractal with the fractal of the river system). All this is true for majority of small and medium-width rivers, but the widest lowland rivers often have more complex banks and have large well visible islands.

Here is a pair of random Earth rivers of medium width from two continents.

It is known that in nature there are almost no classical geometric forms, but fractal forms are very common.

So far we consider only the most frequent behavior of the river channel; ducts, deltas, islands, and old channels that have become oblong lakes we are not considering now. Although, the method proposed further, with some changes, can be applied to create models of these nature forms; at least I find it as promising.

Surely, there are already scientific works devoted to the formation of rivers and it would be possible to model river forms based on the strict physical theory. However, the shape of the mountains could be obtained by modeling based on the strict theory of lithospheric plates movement, weathering, and erosion; but, in order to obtain a plausible terrain for virtual worlds, no one does it (correct me if I’m wrong). For this purpose we use one of the algorithms of the Brownian surface generation.

Similarly, with rivers, we should try to get a fractal shape close to the real river forms, and then we could use it to represent procedural generated rivers on maps.

Again, carefully studying the real earth’s rivers, we can notice some special behavior of the river banks. Two banks most often do not diverge or taper simultaneously (it also happens, but less often). Everything looks so that one bank shore departs from the imaginary central line of the river or approaches to it. This phenomenon makes one think to put one more channel (river bad), different from the first but close to it, atop each other. Then we should get the right behavior of the banks.

So it turned out to be valid.

The second channel is constructed by the random walk method. Each point of the second channel is obtained by shifting the corresponding point of the first channel by a certain vector, which is the same in absolute value (for the current river width), but its direction makes a random walk. When passing to each next point, we add a random value to the last angle value, and the random values is distributed according to the normal (Gaussian) distribution. The points thus obtained are also smoothed.

Obtained channels must be merged in the resulting river polygon. How exactly I merge channels I will recount in the next post. For now a few examples from the planet Admete.

Click the images for bigger image size.

Rivers And Lakes

This is the first of three posts, where I will describe the process of creating river systems in the project. In this post the algorithm for constructing and smoothing rivers will be described, in general terms. The second post will contain information on how to make river banks more realistic. And the third post will be with the program code, which is used to create the final river form.


Firstly, some information about the lakes. In the procedural generation of maps, as a rule, lakes are formed at the moment when sea level is defined. Areas below a certain height is considered water, higher areas are land. Isolated parts of water are lakes.

But in this case we do not take into account all hollows (pits) in the terrain which are above sea level. In nature there can be lakes in such places and rivers can flow into these lakes.

In the project I make a lake in almost each terrain pit, sometimes there is a large lake covers a few pits. It is possible to regulate the limits of absolute or relative depth (in relation to the depth of the pit) of lakes. At the moment, the amount of water flowing into the lake does not affect the size of it and there are no outflowing rivers from lakes. Implementation of these features seems rather complicated, so I postponed it for later. 🙂

Those lakes that are obtained by setting the sea level are also present in the project and are called lowlakes.

River systems

As you can learn from previous posts, the relief is constructing on some two-level regular lattice of points. At the lower level, these are the points inside a rhomb on the projection cone.

At first the river is made as some curved line on the lattice points. The resulting line is called the river line. To put simply, the algorithm for creating a river line is as follows:

  • In each rhomb we randomly select the source point of the new river and then choose the random outflow point on the rhomb edge. Here we must ensure that the height of the outflow point is less than the height of the source point. In the next versions of the project there will be several river sources for a rhomb and their number will vary depending on the type of the terrian and, possibly, the type of the biome.
  • The line inside the rhomb is drawn by the brownian motion simulation method (not exactly what’s on the link but close). Possible loops are eliminated.
  • In subsequent rhombs we draw a line from the source, which corresponds to the outflow point in the previous romb, to the new outflow point.
  • This process continues until we flow into either the ocean, or in a lake pit, or into another already made river (trunk).

There is the special order in drawing river lines, firstly we should draw rivers which have source far from the ocean and in the mountains. By this we achieve what is observed in the Earth rivers: the most big rivers begin in the mountains or far from the ocean.

The river line is far from what we would want to see on the map. To represent the river on the map few more things are required.

  • Smoothing of the river line.
  • Giving the river a width and turning it into a polygon.

In the project I use a simple and effective method of smoothing, which consists in aligning each point as a midpoint between the previous point (already aligned) and the next point (not yet aligned). To better preserve the characteristic behavior of the original line we can pre-insert additional midpoints in the original line, and then make smoothing.

The images of the original (typical) river line and line recieved after smoothing are on this picture.

As it turned out, with the increase in the ‘thickness’ of the river, additional points become excessive, and for the thickest rivers even the initial points of the river line are too many; such rivers become more like a long caterpillar. Therefore, for wide rivers, some points are firstly evenly removed, and the remaining ones are smoothed.

How to draw a line of a suitable width from a thin river line we will study in the third post. Now you can just look at the results on the three pictures below.

On the first picture a river of minimum width of those that are currently depicted on the planets. The second and third pictures show rivers which are by two and four times wider than the first. Respectively, there are only every second and every fourth point remains in them, remainder points are aligned. For rivers with an intermediate width, the uniform elimination of points on the interval can be applied.

Change Log: 0.6.1

  • Rivers get some random variance in their width along the stream.
  • riversz shapefile also gets the trunk field which contains the id of the trunk river in which this river flows into. The special value -3 denotes that this river flows into the ocean. Currently, rivers in riversz shapefile do not take into account lakes.
  • PNG tiles and shapefiles of Admete planet was updated respectively.

In the next 2-3 posts I will describe the process of river constructing. And for a while the river system will remain as it is. At the beginning of the new year I will try to make the planet continents look more like Earth continents with intermittent mountainous and flat areas, and not with one or two central mountains as it is now. The resolution of the planets will still be small (as it is now), it will be increased only after all the significant problems will be solved.

Change Log: 0.6

Quite a large update changing the rivers generation.

  • Visible river width depends on the streamflow (discharge) of water flowing in it.
  • All geographical features data are now in EPSG:3785 projection (Mercator).
  • In addition to rivers as multipoligons in rivers shapefile, there are also rivers as 3D-multilinestrings with z coordinate in riversz shapefile. The latter is a schematic representation of the river system trees.

New example planet added. Also corrected and expanded the tutorial on making a map in the equirectangular projection.

Site update: planet views

Finally, I came to use maps for planet modeling. Using a popular tree.js library I intend to show all new planet maps on the sphere model, along with the flat tile map. Textures for spherical models are made from image maps in the equirectangular projection. Texture files are located in the appropriate planet directories (/planets/<planetNo>/equirectangular.png and /planets/<planetNo>/equirectangular-big.png).

In the tutorials section I added a new tutorial on making maps in the equirectangular projection.

Also, for people who want to do planet modeling with javascript, I made simple helper functions.