Procedural rivers - from origins or estuary?

Started by
2 comments, last by Buckeye 13 years, 5 months ago
Note: I am currently working on algorithm, not on implementation.

My algorithm for procedural filling a predesigned world is as follows:
1. Take input: areas (like mountains, hills, plains, barrens etc.; first of all of course coastlines of islands/continents), climates, pre-placed cities, roads, rivers and lakes.
2. Generate heightmap based on predesigned areas from input (probably using jasjas' libnoise, as it looks friendly with all it's modules).
3. Carve predesigned rivers and lakes.
4. Generate random rivers (and, in the process, lakes) to fill the land (and erosion here).
5. Place pre-placed cities and roads (and some landmarks, if present on input).
6. Generate random cities, villages, roads and so on.
7. Generate vegetation based on: slopes - their angle and direction, near watersources, (generated in this step or before, dunno at this moment how exactly do this - but does not matter now) soil and so on.

I am not exactly sure about few points in detail, but this is about point 4. I want to use pathfinding algorithm to generate rivers (and lakes), with node cost as height, not distance. And here is the question: should I start at river origin (in mountains) and seek for another, "nearest" water (lake/ocean/see/river/w/e) or start at random point at coast and create first river, then it's tributaries?

Any thoughts about that alternatives?
Advertisement
I'd *definitely* start at the coast.

Why?

Because it's really obvious if your pathfinding ends up making rivers not end at the coast.

Whereas it's *much* less obvious if some of your hills don't have rivers to drain into properly.... Who's going to look at a hill and say "There isn't a river close enough for rainwater to drain into"??

Always start with the more obvious bit (which is the estuary in this case) and the less obvious will often just hide itself.

Heh, for me more obvious is starting a river from spring, as rivers flow to coastline/other rivers, not from them ;p

As for river ending in the middle of nowhere: if I use pathfinding algorithm, I tell it to say that it found a river, when that river hits other river/lake/coastline.

And as for "there should be a river", I though about making a river by erosion algorithm: if to much water flows there, then find a way to make realistic river.
As an alternative (as you seem to be approaching anyway), you could simulate the real world. Water accumulates in an area and flows downhill to local low areas.

If you have a heightfield, start at some high location. From that location follow the local horizontal or downward tangents to the terrain, accumulating distance traveled. The size of the "river" depends on the distance traveled, assuming total drainage at a location is proportional to the length of the river. If you reach a local minima, look for a "close-by" location that is lower, "erode" to that location and continue.

If your heightfield is reasonable, most rivers will reach the coast.

Note: it's sort of backwards as real-world drainage paths are determined (mostly) by erosion to begin with.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement