Jump to content

Ultra Software Company Blog

  • entries
    188
  • comments
    1,259
  • views
    685,881

Contributors to this blog

Procedural Terrain


Josh

7,927 views

 Share

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.

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:

Image21.jpg

 

Fractal noise provides a better appearance, but it still looks "stylized" instead of realistic:

Image23.jpg

 

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.

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:

f1.jpg

 

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:

f2.jpg

 

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:

f3.jpg

 

We next blend in some Fractal noise, to roughen the landscape up a bit and add some high frequency details:

f4.jpg

 

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.

f5.jpg

 

Here is an animation of the entire process:

Animation1.gif

 

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.

Image19.jpg

 

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.

  • Upvote 10
 Share

8 Comments


Recommended Comments

That's awesome! Now, what would be really cool is if this could be combined with an imported heightmap. E.g., if you use real-life elevation data, their resolution is typically too low for games (for SRTM data it's 30m per pixel in the US and 90m worldwide). So you have to "enhance" them to make them visually interesting, like adding some Perlin/fractal noise and eroding some of it afterwards.

  • Upvote 1
Link to comment

Nice Josh! Don't be afraid to throw in some crazy non realistic optional filters as well if you like. You could hide them under a seperate tab so people would know that they are special operations

Link to comment

The final result is really impressive. Reminds me of Borderlands terrain; lots of playable plateau areas and realistic, sharp cliffs.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...