Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Roads & Rivers in Dynamic Procedural Terrain

This thread is locked; no one can reply to it. rss feed Print
Roads & Rivers in Dynamic Procedural Terrain
Anomie
Member #9,403
January 2008
avatar

I don't think 'dynamic' is super appropriate, but uh... :-/ Anyway, I was messing with some procedural terrain and I'm stumped on something:

1. I'm generating new terrain blocks as the player enters them.
2. I want contiguous/sane roads and rivers that traverse many blocks.

I'm using Perlin noise and some simple fiddling to get the basic terrain that I have now, and this gives me fairly nice lakes or ponds, which I considered connecting at random to generate passable rivers. The only problem is that I can't do this without pre-generating some adjacent terrain blocks.

Another important point is that I'm doing this in real time in AS3, so I'm more concerned with playability and speed than with realism. Here's what I've got so far:

http://cltatman.com/misc/generator.swf

Anyone have any ideas? :(

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

OICW
Member #4,069
November 2003
avatar

There's an interesting ACM article from 2005: Audiben, P., Belhadj, F - Modeling landscapes with ridges and rivers: bottom up approach. Although it's not purely dynamic, i.e. you have to pre-generate the terrain patch.

In the first step they sprinkle the patch with ridge particles which are subsequently subjected to Brownian motion, this gives you ridge network. Second step consists of heavy sphere particles creating rivers. Finally they use classic mid-point displacement coupled with interpolation to get the rest of the terrain.

You can think of it as generating terrain with constraints. I'm still looking for other solutions as well, though I plan to fiddle with this in my project as well.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

gnolam
Member #2,030
March 2002
avatar

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Anomie
Member #9,403
January 2008
avatar

@OICW: I can't investigate at the moment, but does that method only require a single terrain patch to be rendered, or the entire collection of patches that contain the river?

@gnolam: Something like that, except that I'm only generating terrain three screens at a time. I'm having trouble generating sensible macro-structures one chunk at a time.

Maybe I can do some peeking into adjacent blocks without generating them completely, I'll have to do some more work on it today.

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

OICW
Member #4,069
November 2003
avatar

Well, in the examples they were generating 1024x1024 single patch. It took them approximately 4 seconds on modern CPU (don't remember specs at the moment). However, nothing prevents you from adapting the method to generate adjacement patches or one big patch and dividing it into smaller ones.

Though, it all depends on what exactly do you want to do with it. I presume you'd like to generate the terrain on the fly without storing the heightfield. That could be quite tricky, but I think it can be done. One has to fiddle with ridge/river particle generation code, so both can propagate between adjacent regions.

EDIT:
Silly me, I forgot to thank gnolam for posting that link. That's quite useful resource. Something I haven't thought about, now how to fit it in spherical case.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Anomie
Member #9,403
January 2008
avatar

OICW said:

Well, in the examples they were generating 1024x1024 single patch. It took them approximately 4 seconds on modern CPU

I'm only generating a 240x180 tilemap for each block, but I definitely can't spend 4 seconds on it. I've got my base terrain generation under 40ms, but I think I could manage more without noticeable delay using some progressive generation to split the work across several updates. My goal is to do this with only slight stuttering as new blocks are generated.

Quote:

I presume you'd like to generate the terrain on the fly without storing the heightfield. That could be quite tricky, but I think it can be done. One has to fiddle with ridge/river particle generation code, so both can propagate between adjacent regions.

The heightmap is based on noise which I can store, but generating more than two or three chunks of noise (roads or rivers would certainly populate more than that?) is too expensive to do during the generation of a single terrain block.

I don't have anything new to report, but I think I might try to generate a low-res, lo-fi noise map that encompasses many terrain blocks, and use that to define large structures.

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

weapon_S
Member #7,859
October 2006
avatar

Couldn't you use a much simpler generator for roads and rivers, and just overlay that over the terrain? Like a simple tree generator? You would have to accept connecting lakes would be serendipitous, and roads might not follow a 'smart way' over the height map. You'd use a 'seed' based on the neighbour's, so roads would connect.
That generator seems to give the same terrain, unless I clear the browser cache. Any regeneration hot-key?

Anomie
Member #9,403
January 2008
avatar

weapon_S said:

That generator seems to give the same terrain, unless I clear the browser cache. Any regeneration hot-key?

The generator is generating each terrain block dynamically each time you visit it, but it's all based on the same seed. I wouldn't recommend trying to use it right now though, it's currently a failed experiment to convert everything to tilemaps instead of pixels. :P

Quote:

Couldn't you use a much simpler generator for roads and rivers, and just overlay that over the terrain?

The road/river generation process would hopefully be fairly simple using the macro-noise, but I haven't been able to work on it much lately.

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

Go to: