For Sea of Treasures and another unreleased game project I created a procedural way to generate terrain on mobile. Everything is done within Unity.

It starts from a Voronoi Diagram, to generate a loose grid of triangles (in black) or regions (in white) linked together.

VoronoiDiagram.jpg

From there a few basic functions and noises can be used to set a base heights to generate a slope or simple height maps. We can add water by choosing a water level and changing the visuals above and below this level, per triangle.

At this point it is already possible to use a height map of an island (from real life or from another software) and use this as elevation data to have an island, but I wanted infinite number of islands and terrain. I also wanted to have more information than just the elevation, I wanted lines of erosion, wind, political regions, and control over the terrain to manage difficulty and overall gameplay.

I then generate a 3D mesh from the triangles and keep a bijection between my 3D mesh and my voronoi diagram (earlier picture), because we will need it to navigate and modify the terrain data. The mesh is just a puppet, a representation of our data.

Here is a view in 3D with some basic elevation and noise and a super simple shader:

Elevation1.jpg

The next step is the most important: computing erosion. First we decide the slope direction for each triangle, this makes a huge directional graph from the mountain tops to the depth of the sea where each triangle is linked to one (and only one) neighbouring triangle lower than him.

Then we simulate water flowing from the tops, and lower the elevation based on how much water total flows in each triangle. We just eroded the terrain based on water flow! It’s a big approximation of millions of years of nature and it could be a lot more complicated to reflect real geological features of the earth, but for now this is enough for our mobile games.

We computed erosion but we have a lot more than just erosion, we know where water is flowing on our map, so we can also use this to draw basic rivers. We could also use it to determine how dry or wet a region is.

The following images show basic height maps that have been eroded:

Then we have a lot of shader work to do, and some data cleaning for the shores, to smooth the rivers and find ways to generate cool looking terrain using as little triangle resolution as possible.

More shader work and tech art to generate UVs based on elevation. It’s a lot trickier than it seems. Look at the oceans! It’s not realistic at all, but it’s fine.

Remember how all this started from a mathematical structure of Voronoi and see how now it’s shaping to become beautiful art. Step by step our map is coming to life. Next I’m showing the four seasons on the same map.

Here a lot of small details were added, a paper effect on top and below, an edge and a table background, and finally some clouds and particle effects. Rivers are also a lot more visible.

And that’s it for the procedural generation of a map! Thank you for reading.

Erosion Lines

Erosion Lines

Wind direction

Wind direction

Programming - Alexis Bacot
2018

Previous
Previous

Sea of Treasures

Next
Next

Bact'Attack