Procedural Terrain

Published July 29, 2013
Advertisement
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']I wanted to add some default procedural generation tools in the Leadwerks 3.1 terrain editor. The goal is to let the user input a few parameters to control the appearance of their terrain and auto-generate a landscape that looks good without requiring a lot of touch-up work.[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']Programmers commonly rely on two methods for terrain heightmap generation, Perlin noise and fractal noise. Perlin noise produces a soft rolling appearance. The problem is that Perlin noise heightmaps look nothing like real-life terrain:[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']Image21.jpg[/font][/font][/color]

[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']Fractal noise provides a better appearance, but it still looks "stylized" instead of realistic:[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']Image23.jpg[/font][/font][/color]

[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']To get realistic procedural terrains, a more complex algorithm was needed. After a few days of experimentation, I found the optimal sequence of filters to combine to get realistic results.[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']We start with a Voronoi diagram. The math here is tricky, but we end up with a grid of geometric primitives that meet at the edges. This gives is large rough features and ridge lines that look approximately like real mountains:[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']f1.jpg[/font][/font][/color]

[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']Of course, real mountains do not have perfectly straight edges. A perturbation filter is added to make the edges a little bit "wavy", like an underwater effect. It gets rid of the perfectly straight edges without losing the defining features of the height map:[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']f2.jpg[/font][/font][/color]

[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']The next step is to add some low-frequency Perlin noise. This gives the entire landscape some large hills that add variation to the height, instead of just having a field of perfectly shaped mountains. The mixture of this filter can be used to control how hilly or mountainous the terrain appears:[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']f3.jpg[/font][/font][/color]

[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']We next blend in some Fractal noise, to roughen the landscape up a bit and add some high frequency details:[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']f4.jpg[/font][/font][/color]

[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']Finally, we use thermal and hydraulic erosion to add realistic weathering of our terrain. Thermal erosion works by reducing the harshness of steep cliffs, and letting material fall down and settle. Hydraulic erosion simulates thousands of raindrops falling on the landscape and carrying material away. This gives beautiful rivulets that appear as finger-life projections in the height map: Rather than relying on conventional hydraulic erosion algorithms, I created my own technique designed specifically to bring out the appearance of those features.[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']f5.jpg[/font][/font][/color]

[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']Here is an animation of the entire process:[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']Animation1.gif[/font][/font][/color]

[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']And in the renderer, the results look like the image below. All the parameters can be adjusted to vary the appearance, and then you can go in with the manual tools and sculpt the terrain as desired.[/font][/font][/color]
[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']Image19.jpg[/font][/font][/color]

[color=rgb(11,25,2)][font=arial][font='Helvetica Neue']The new landscape has ridges, mountains, and realistic erosion. Compare this to the Perlin and fractal landscapes at the top of this article. It's also interesting that the right combination of roughness and sharp features gives a much better appearance to the texture blending algorithm.[/font][/font][/color][color=rgb(0,0,0)][font=arial] [/font][/color]
11 likes 9 comments

Comments

DE5

Very useful work. Thank you for sharing.

July 31, 2013 07:26 AM
swiftcoder

Very nice! It's interesting that we both converged to roughly the same set of steps in our terrain generation (voronoi perlin + hydraulic erosion) - I think it's a fairly optimal approach to generating nice-looking terrain.

July 31, 2013 12:49 PM
Josh Klint

Very nice! It's interesting that we both converged to roughly the same set of steps in our terrain generation (voronoi perlin + hydraulic erosion) - I think it's a fairly optimal approach to generating nice-looking terrain.

I actually came across some blogs you wrote a while back that helped me get the initial direction. Thanks for writing those.

July 31, 2013 05:00 PM
noizex

Could you go into more details about these erosion algorithms? Perlin / fractal / voronoi are known pretty well already, but it would be interesting to hear more how did you achieve the last effect, whats computational overhead of doing that last "pass" - is it suitable for real-time terrain generation?

July 31, 2013 07:40 PM
Josh Klint

Ah , but that part is the secret sauce. Basically, I just wrote a raindrop simulator and let thousands of random raindrops fall down and carry material away from the mountain. Maybe I will cover it in more detail at GDC 2014. :)

August 01, 2013 07:40 AM
Krohm

Thank you very much! I'll have to remember about that.

August 02, 2013 04:36 AM
swiftcoder
Raindrop-based hydraulic erosion is pretty cheap. I've seen several GPU-based implementations that run very nice animated demos in realtime...
August 02, 2013 09:17 PM
TheChubu

Yep, this guy here has a real time demo that you can run with a WebGL enabled browser:

http://codeflow.org/entries/2011/nov/10/webgl-gpu-landscaping-and-erosion/

Though at least in Chrome it gets broken every now and then.

August 03, 2013 07:16 PM
Dare

Thank you for a nice collection of algorithms gathered in one place.

I myself spent countless hours on terrain generation in the past. Currently in our engine, we use procedural algorithms mostly for closeups. I would suggest the next step is bringing in some layered materials.

Otherwise good job.

August 05, 2013 08:57 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement