Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Generating rivers....

1,763 views
Skip to first unread message

spag

unread,
Aug 22, 2008, 1:26:30 AM8/22/08
to
I've been having issues with rivers. Actually all out door scenery,
but I'm at least just trying to come up with a basic terrain with
water on it.

So, I want to come up with some procedural way to generate a river on
my terrain. Just wiggling a 2D fractal line across the screen isn't
going to cut it. I'd like for it to branch sometimes, maybe have two
river sometimes (splitting the land mass into thirds), possibly even a
circular deal with an island in the middle.

I've played with fractal terrain height maps and setting arbitrary
water levels, but it's not really the look I want. Ultimately it all
gets mapped to characters and all, but I still end up with bits of
land where I don't want them and all.

Ideas? I've seen people talk about using automata to generate
terrain, but I can't think how that would be done.

Is there even a procedural way to do this? I'm tempted to cheat and
just use some kind of templates, but I know I'll never be happy doing
it that way.

dominik...@gmail.com

unread,
Aug 22, 2008, 2:29:54 AM8/22/08
to

Maybe my developer's article will be of some help:
http://umbrarumregnum.110mb.com/art5.html
You can modify it and use more than one starting point for the river.
Since the endpoint is the same, the river will naturally join the main
flow.
Hope that helps somehow.

Mingos.

Xecutor

unread,
Aug 22, 2008, 3:48:08 AM8/22/08
to
Many years ago, when I tried to create remake of 'Master of Magic' and
was working
on terrain generator, following algorithm worked pretty well:

random point inside continent was choosen as source,
as well as random direction - general river flow direction.
With each step in flow direction there
is chance to turn or branch.
Splitting chance is significally lower.
If turn rolled, river change direction for 1-3 steps,
than return direction to normal.
If branch rolled - both childs shouldn't turn to each other side for
several turns.
There was several cells lookahead, so that when ocean is close
enough intensive branching was forced.
In my case every continent was surrounded by water,
so 'end of algorithm' condition was - another water piece reached.

Paul Donnelly

unread,
Aug 22, 2008, 3:56:06 AM8/22/08
to
spag <spagt...@gmail.com> writes:

> I've been having issues with rivers. Actually all out door scenery,
> but I'm at least just trying to come up with a basic terrain with
> water on it.
>
> So, I want to come up with some procedural way to generate a river on
> my terrain. Just wiggling a 2D fractal line across the screen isn't
> going to cut it. I'd like for it to branch sometimes, maybe have two
> river sometimes (splitting the land mass into thirds), possibly even a
> circular deal with an island in the middle.

I don't think rivers generally branch (although I won't say it never
happened). Mostly they do the opposite. How about starting several
rivers heading toward roughly the same point, and joining them
together when they meet?

jot...@hotmail.com

unread,
Aug 22, 2008, 9:10:38 AM8/22/08
to
On 22 Ago, 08:56, Paul Donnelly <paul-donne...@sbcglobal.net> wrote:
> I don't think rivers generally branch (although I won't say it never
> happened). Mostly they do the opposite. How about starting several
> rivers heading toward roughly the same point, and joining them
> together when they meet?

Start them in the ocean and then branch them as they move uphill :)

Jotaf

Ido Yehieli

unread,
Aug 22, 2008, 9:56:52 AM8/22/08
to

Rivers move uphill?

Slash

unread,
Aug 22, 2008, 10:16:23 AM8/22/08
to

Of course not, but naive players will never notice!

--
Slashie

Soyweiser

unread,
Aug 22, 2008, 10:45:52 AM8/22/08
to

The flow of the river sweeps you into the mountain. You drown in the
mountain. DYWYPI?

--
Soyweiser


Slash

unread,
Aug 22, 2008, 12:00:54 PM8/22/08
to

Well, the river direction would be contrary to the used while
generating it, player just wont notice you generated it backward :P

--
Slash

spag

unread,
Aug 22, 2008, 11:03:48 PM8/22/08
to
On Thu, 21 Aug 2008 23:29:54 -0700 (PDT), dominik...@gmail.com
wrote:

>Maybe my developer's article will be of some help:
>http://umbrarumregnum.110mb.com/art5.html
>You can modify it and use more than one starting point for the river.
>Since the endpoint is the same, the river will naturally join the main
>flow.
>Hope that helps somehow.
>
>Mingos.


I'll probably give something close to that a try. A* through a height
map might work, I'll have to play around with it some. Might look
better through noise like you talk about, but I don't have any current
code for generating that. I tried doing some stuff with Perlin noise
a while back, and could never get the combination of variables right
so that it gave me the look I was going for.

Thanks.

spag

unread,
Aug 22, 2008, 11:08:47 PM8/22/08
to


This is kind of what I ended up with, at least picking the starting
poing and wandering from there, but the way I did it doesn't look
right to me.

Combining that with the path finding might though. Starting in the
middle, and working to two (or more) edges from there.

spag

unread,
Aug 23, 2008, 6:08:24 AM8/23/08
to
That actually worked. I think my A* routine is a little shakey since
I had to convert it over from a hexagon based RL I was playing with,
but works reasonably well. I just get a little more hunting than I
ever seemed to get with the hexes. Probably won't matter once I make
the stream wider.

At first I was having a rough time getting the height map data to be
meaningful enough to actually change the course since the values I was
using were too large. I used your idea of multiplying the facing
value (5 or 7 for diags) with a normalized map (0..1), and it follows
the terrain pretty well.

I haven't gotten ambtious with splitting it or anything, but it looks
pretty good for single streams. Thanks again.

Malorzean

unread,
Aug 24, 2008, 4:44:03 AM8/24/08
to
> Maybe my developer's article will be of some help:http://umbrarumregnum.110mb.com/art5.html

Could you possibly add these articles to roguebasin? They're certainly
interesting new ways of looking at old problems and it would be good
to have them there. If its too much trouble, do we have your
permission to upload them to roguebasin?

Thanks
Malorzean

Malorzean

unread,
Aug 24, 2008, 4:56:07 AM8/24/08
to
Also, When you talk about 2D fractional brownian motion, is that just
a random walk in 2D, or what is it exactly?

Thanks again,
Malorzean

spag

unread,
Aug 24, 2008, 2:58:08 PM8/24/08
to
On Sun, 24 Aug 2008 01:56:07 -0700 (PDT), Malorzean
<malo...@gmail.com> wrote:

>Also, When you talk about 2D fractional brownian motion, is that just
>a random walk in 2D, or what is it exactly?
>
>Thanks again,
>Malorzean


The random walk in 2D of course wouldn't look right for a river, it
just meanders all over the place. I've done 2D fractal lines before
for a side profile of terrain, and while that simulates a more natural
looking line, still wasn't doing it for me.

You can use brownian motion to create 2D height maps, which you can
use to create cool 3D terrain models, planet surfaces, etc. Not a
really in depth article, but a good starting point here:

http://www.gamasutra.com/features/20010302/oneil_02.htm

Once you have a height map, letting the river "flow" using a shortest
route algorithm between two points works pretty well. It's not going
to be technically accurate, as it's possible that the shortest route
could end up having to take the water up hill to make it happen, but
it looks good.

I suppose to be technically accurate, you could do a two pass thing
over the height map. Generate it first, get the path of the river,
and then go through an lower the map along the path over the river
below some threashold. I don't think it would matter much if
converting it all to ascii, but I don't know, someone might want to
make movement costs associated with moving through terrain like that
cost more, and moving along the shores of a river would tend to cost
the least because they are often flat.

-spag

dominik...@gmail.com

unread,
Aug 27, 2008, 2:27:01 AM8/27/08
to

I can't recall whether I actually gave my permission on Roguebasin or
not to wikify my articles... If not, I'll add myself to the permission
list tonight. You can wikify my articles if you feel they're useful,
of course, I have no problem with that.

When I speak of any kind of noise, be it Perlin noise or fBm, I mean
the algorithms included in Jice's tcodlib, since they're exactly what
I use. They're usually just 2d noises, not random walk, Brownian
island generation nor anything similar.

Mingos.

dominik...@gmail.com

unread,
Aug 27, 2008, 2:30:25 AM8/27/08
to
On 24 ago, 10:56, Malorzean <malorz...@gmail.com> wrote:
> Also, When you talk about 2D fractional brownian motion, is that just
> a random walk in 2D, or what is it exactly?

Like I said in the above post, noise, not random walk. I don't really
know how it works, since the algorithm isn't mine. fBm, from what I
understand, is a sum or interpolation of several Perlin noises with
different zoom values or something like that. You'd need to ask Jice
about how he implemented it and what information sources he used...

Mingos.

aave

unread,
Aug 27, 2008, 4:02:56 AM8/27/08
to
Gamedev.net has an article about rivers:
http://www.gamedev.net/reference/programming/features/randomriver/
It is quite similar to what have been discussed here already, but
features some code too. I remember that there was an other one too,
that was more tile orientated, but I can't find right now.

On the topic of Perlin noise and fBm, wikipedia is always helpful:
http://en.wikipedia.org/wiki/Perlin_noise (looka ta the images for
example)
The article has links you can follow further and google finds more. :)

jice

unread,
Aug 27, 2008, 4:55:38 AM8/27/08
to

Indeed, libtcod's fbm is a fractal sum of 2D perlin noises. You take a
perlin noise, it gives you big flat hills. You add a scaled down
version, it results in smaller hills on top of the big hills. You
repeat the process until the details are small enough. The number of
steps is called octave.

A good resource on Perlin noise is (surprisingly!) Ken Perlin's
website :
http://www.noisemachine.com/talk1/

--
jice

dominik...@gmail.com

unread,
Aug 27, 2008, 4:57:23 AM8/27/08
to
On 27 ago, 10:02, aave <tapiovier...@gmail.com> wrote:
> Gamedev.net has an article about rivers:http://www.gamedev.net/reference/programming/features/randomriver/
> It is quite similar to what have been discussed here already, but
> features some code too. I remember that there was an other one too,
> that was more tile orientated, but I can't find right now.
>
> On the topic of Perlin noise and fBm, wikipedia is always helpful:http://en.wikipedia.org/wiki/Perlin_noise(looka ta the images for

> example)
> The article has links you can follow further and google finds more. :)

Thank you for the link, aave. This is exactly what I mean when talking
about noises, either Perlin or fBm.

By the way, the idea about making rivers sprung to my mind after
reading one of the pages the wiki links to: the one about creating a
random universe, which uses the noise's absolute values as well :). It
might be interesting to read even if one's not interested in creating
rivers since it might be potentially useful for many things, not only
in procedural random world generation.

Mingos.

0 new messages