Terrain Solver

cover

4 min read

Intro

Let us explore the topic of terrain generation, with a particular focus on the tools designed to create expansive landscapes. Many of these tools operate on a shared foundational principle: the use of a single dimension to represent elevation. This approach is commonly employed in software such as Houdini.

However, this method encounters significant limitations when applied to terrains with extreme height variations. Features such as cliffs and canyons often become distorted, losing their intended form and detail.

This project is dedicated to addressing these limitations. Its primary objective is to improve the accuracy and fidelity of terrain generation in areas where conventional methods prove inadequate.

Problem

Let’s consider the terrain in the image below. This height field began its life in Houdini and was then exported to Gaea for some fine-tuning. Here’s where the issues start to emerge. In the cliff areas the detail is lost. The traditional fix would involve either filling these problem areas with pre-made rocks from a library or manually sculpting the meshes to match the desired topology of the landscape.

Both methods come with their own set of challenges. Relying on a library of assets—like Megascans can be restrictive, as those assets might not always align with the production’s art style. Plus, using the same rocks across a large area can lead to noticeable repetition. On the other hand, having environment artists sculpt custom assets from scratch is time-consuming and can become costly, especially if the production undergoes frequent changes.

While browsing SideFX’s features page, I came across someone who shared the same frustrations. Inspired by their approach1, I decided to tackle the issue myself and implement my own solution following their approach.

some

Shapes and Time

Just as in the erosion processes modeled with Houdini’s landscape operators, this tool is a solver, and the shapes evolve over time based on their previous state. At the beginning the setup of the process involves setting a base resolution of the mesh, a target density resolution and the time the simulation will take.

The rock shapes are modeled from a simple voronoise function layered with many other noise functions. These functions can be animated during the simulation to alter the growth shape.

Additionally there are functions to push the edges towards the most prominent features or towards areas with a steep change in the curvature. This push has the effect of making the shapes more sharp and defined.

features development with erosion

Erosion for Steep Areas

This solver takes also the results from Houdini’s terrain erosion, and uses areas marked as soil or rock to run a custom hydraulic erosion solver that runs over the 3d geometry to create weathering effects. (Unlike Houdini’s stock erosion operators)

features development with erosion

On a larger scale, the erosion of the soil can also reveals more areas that become a target for rock growth.

some

The erosion also can transport material by moving soil material downwards, following the path of water flow, leaving behind deposits of rock and debris.

some

Technical Bits

In this solver the domain geometry is remeshed in each frame, increasing the detail as the time advances. To keep the shape of the rocks independent from the resolution, a “rock map” is calculated each frame. At the core of this rock map is a voronoi function with accurate edge distance calculation and ids output. This function was adapted from Inigo Quiles article on accurate voronoi edge distances2 with a few modifications to make the code more readable.

  1. Water paths from gradient descent
  2. Random feature growth direction using each voronoi site seed
  3. Rocks map VOP
  4. The core of the solver is a custom voronoi function implemented in VEX, it provides accurate edge distances

Next Steps

The output from this terrain solver provides data that can be used not only for applying base colors to the geometry’s vertices but also for creating tagged areas that kickstart the texturing process.


Footnotes

Footnotes

  1. https://www.sidefx.com/hydra-studios/

  2. https://iquilezles.org/articles/voronoilines/

Published: Aug 15 2024
Updated: Aug 15 2024