2
\$\begingroup\$

I'm aware of many methods for procedurally generating rivers, but they require an entire heightmap beforehand in order to work. For instance, they may require to find a high position on the map and find a path to the ocean.

But when working with on-demand / on-the-fly procedural generation (generating the map around the player as he moves), those requirements are unfeasible. For instance, Minecraft doesn't have "true rivers":

the river does not in fact have a start and end point, it is actually just dividing the two biomes, this means that it uses the distance between the point and the edge of the biome to determine how deep the water should be, with some variance of course.

This mod seems to solve the issue, but how? Probably it takes advantage of the fact that entire chunks are generated and thus is not entirely on-demand per position.

So, the question is: how can I generate rivers procedurally on-demand? More preciselly, I want a function f(x, y) which tells me whether there is a river at (x,y) or not (and its flow direction). It seems pretty unsolvable for me, but maybe people have come with some solution.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ If you want to know more about how that mod works, read its forum thread & source code. \$\endgroup\$
    – Pikalek
    Aug 26, 2016 at 19:12

1 Answer 1

1
\$\begingroup\$

It depend if you want an infinite terrain or not, if you don't have infinite terrain you might be able to generate an idea of where the sea is, it wouldn't be impossible in infinite terrain but you would have to planned it at design time (frequency of land).

But the biggest realization is that you should use correlation instead of cause. River always flow down, therefore you know it define the slope of a mountain, it's easier to place a mountain that follow a river than a river that follow a mountain (and have control), river are basically line segment.

The way I do it is that I tend to have a hierarchical implementation: for example infinite world can be define as increasing partition in the form of sector -> region -> area -> chunk -> block, let's say that each contain 10 division of the zone below, you can generate data that is global to this zone and pass it to his children to process through progressive refinement.

So a sector can have two point as a data that mark that mark the beginning that will be the basis for further generation in a lower level, like using the direction as a gradient to prescribe slope and distance field to be sure that thing are place relative to the river. The idea is also that big feature is also happening at parent, so ocean existence are a matter of the highest level, which would allow you to compute neighbor state and infer proper direction.

It's also possible to have infinite circulation across infinite distance (for example let say you are doing an infinite city) as long as the dependency is only on direct neighbor and no more. For example let say you generate one or more point inside a zone, you can compute circulation (how they are linked) then compute data (here points) from the neighbor to get the connectivity. Because you would use coherent generation the circulation will remain unbroken in both direction, how you generate the actual path is up to you.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .