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.
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.
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.
> 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?
Start them in the ocean and then branch them as they move uphill :)
Jotaf
Rivers move uphill?
Of course not, but naive players will never notice!
--
Slashie
The flow of the river sweeps you into the mountain. You drown in the
mountain. DYWYPI?
--
Soyweiser
Well, the river direction would be contrary to the used while
generating it, player just wont notice you generated it backward :P
--
Slash
>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.
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.
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.
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
Thanks again,
Malorzean
>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
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.
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.
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. :)
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
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.