Today we're going to start a series that dives into Fableforge's terrain generation system! There's a lot of things to talk about, so let's hop right in!
A Divided World
Each cell represents an individual region.
Fableforge is a large and expansive world that is generated on the fly. As you explore the world you will encounter different regions. These Regions are created using cellular noise and everything that is generated inherits from the region in which it spawned in. This includes heightmaps and structures.
A region's heightmap consists of a random number of pseudorandom noise layers, these layers are added on top of each other to create the final heightmap. They are then blended together to create a seamless environment. I will talk more about these layers in just a bit, but there is one noise layer that should be introduced first!
Creating Continents and Oceans
Continental and oceanic regions.
A base heightmap is generated first. This is the foundation of all the other heightmaps that are generated from the regions. The purpose of the base height map is to create large continents and oceans so that the regions can be built on top of it.
The base heightmap provides a smooth transition from continents to oceans. This heightmap does not exceed the height of the sea level. This is due to a couple of reasons.
1. Continents would have a gradually increasing elevation the closer you are to the center. This would cause every continent to be a little bit too predictable.
2. It allows for wetlands to be generated if the region's heightmap allows it.
Each region knows whether or not they are on a continent, or in the ocean, or even both! This is done by sampling the base heightmap at certain positions within the region. With this information the region can determine if it's a continental region, a coastal region, or an ocean region.
Knowing where the region is on top of the base heightmap helps with naming the region! If it is in the ocean it can be called a sea if the height is not as deep as an ocean, or an Island if the region generates a heightmap with a high enough altitude.
Later on this will also help determine what resources and creatures generate in that region too! Some creatures will spawn in deep oceans, while others will spawn closer to the coast.
Region heightmaps are represented within some of the cells.
Each region has a random number of noise layers that it generates. Each noise layer chooses a type of landscape to create, with each landscape having their own rules for generation. These landscapes currently include:
This landscape has a low amplitude and a typically high frequency. The height generated can be lower than sea level, causing a wetland to form. Plains can be smooth or rough, depending on the frequency.
This region consists of many different types of landscapes, but a plains landscape can be seen to the close left and center. This plains landscape is extremely flat compared to most others you'll find. It has a lower than average amplitude, causing the beach to stretch out far from the coast.
Moderate to high amplitude with a low to moderate frequency. Hills can appear as very gradual elevation shifts almost comparable to a plains landscape, to rolling hills, to large and volatile elevations.
Slightly rough hills with a moderate amplitude with low-lying clouds and trees dotting the landscape.
Very high amplitude with a low frequency. Mountains can be gigantic landmasses with a smooth slope, or very steep and rough.
Large, steep mountains seen to the left. A whole mountain range decided to become a cliff in the center! A steep plateau can be seen on the right.
Low to moderate amplitude with a moderate to high frequency. Rocks are abrupt changes in elevation that can generate as huge builders and pillars or small rocks. They can either be isolated around a region, appear in groups, or scattered abundantly throughout the terrain. They consist of a block that is different from the surface block, typically stone.
A coastal rock can be seen barely poking up from the surface of the water!
The landscapes that form each heightmap are very versatile. Fableforge's terrain engine takes a laissez faire approach to procedural generation. This allows for interesting surprises you'll come across as you explore your world!
Each landscape has random variables that are decided by the region. Regions can have multiple of the same type of landscape, but with different variables. Some landscapes allow plateaus, and a number of different plateaus at different heights.
On top of all this, regions can use the heightmaps of adjacent regions!
Transitioning Between Regions
The jittered borders represent the heightmaps meshing together. The red circles show the range at which the region's heightmap strength falls off from the region's center point.
Each region has a center point, this is where the region's heightmap is at its greatest strength. Regions also keep track of what other regions are nearby. When generating the final heightmap, each region will take into consideration the adjacent region's heightmap.
The distance from the center point of a region is calculated. This value is then used to dampen the strength of a region's heightmap, creating smooth transitions from region to region.
As you can probably tell by now, the terrain generation can get pretty complex. This helps create interesting and unique regions that are fun to explore! But this is only the surface! (Get it? Heightmap, surface? Alright anyways..)
We've already touched on how the world is divided, the creation of continents and oceans, different landscapes, and how regions transition from one to the next. There's still more to talk about! Next time we'll take a look at generating structures, trees, caves, rivers, cliffs and overhangs!