Terrain Generation III: Environments




Welcome to the third part of the Terrain Generation series! This time we're going to take a closer look at how the terrain generation system procedurally generates different environments.


What is an Environment?

A snowy, forested environment with occasional flowers and wild grass.



Environments are much like biomes, they determine what type of blocks, trees, and creatures spawn. The difference is that in Fableforge's terrain generation system the 'biomes' themselves are procedurally generated.


Because a biome seems to represent a predefined type of terrain that a procedurally generated terrain system chooses to represent a certain part of the world, I opted to call them 'environments'. In Fableforge, environments aren't predefined like the biomes you'd see in other procedurally generated worlds. They are, just like landscapes (see part 1), also procedurally generated.


How Do Environments Work?

Palm trees, sand, and arches



An environment is a collection of blocks, structures, and other variables the terrain generation system uses to populate a region.


First, an environment needs to know the average temperature and humidity of a region. Average temperature and humidity are determined by sampling noise values within the region. Once we figure out these variables we can now determine what blocks and trees we can use.


An environment requires a few different types of blocks. They are the following:


- Primary block(s): The block(s) that spawns on the surface.

- Flora block(s): The block(s) that spawns on top of the primary block.

- Secondary block: The block that spawns below the primary block.

- Subterranean block: The block that spawns below the secondary block.

- Coastal block: The block that spawns near sea level and the sea floor.

- Sea block: The block that spawns in seas/rivers/lakes.

- Mountain block: The block that spawns when the landscape generates a mountain.

- Mountain peak block: The block that spawns on mountains at the highest altitudes.


Pine tree forest with yellow flowers



The environment selects a compatible block for each category. Here's a list of compatible blocks for each category that are currently in the game:


Primary block(s): Grass, sand, snow, dirt, stone

Flora blocks: Wild grass, red flower, white flower, yellow flower

Secondary blocks: Dirt, stone, sand, snow

Subterranean blocks: Stone

Coastal blocks: Sand, dirt, stone, snow, grass

Sea blocks: Water, ice

Mountain blocks: stone

Peak blocks: stone, snow


Note: The list is pretty limited at the moment and more blocks will definitely be added in the future.


Each of these blocks have a favored temperature and humidity. If a block's favored temperature and humidity is close enough to the region's averages then that block will be added to a list of considered blocks.


Each block in the list is given a probability of being chosen. The probability is determined by how similar the favored temperatures and humidities are to the region's average temperature and humidity.


The environment will then randomly choose a block from this list. Some categories like primary blocks and flora blocks allow more than one block to be placed. In this case, each block that is chosen will also have a certain chance of spawning.



A heavily forested hill



Environments also decide what trees spawn and how often! The region's tree spawn rate is a random value influenced by the average humidity. Low humidity usually means not many trees, and vice versa. This also extends to flora blocks like flowers and wild grass.


This system allows for a variety of things that can occur. We can have hot grasslands, which in the future can determine the type of weather and creatures that spawn. We can have a varied world where you won't see a bunch of desert regions adjacent to each other because that part of the world is hot (it's still possible though of course, just rare). You also will most likely not see desert regions near snow regions (again, it's still possible but rare. Which is fine, because the objective of this system is to create a fantasy world, not necessarily a realistic one)



Tiny islands of grass and sand with rocky coasts.



Fableforge's procedural generation is meant to be very flexible. But sometimes extra flexibility can cause unexpected results, and because of this there are some certain rules that the terrain generation system goes by. Dirt and stone are primary blocks, but cannot be the most probable primary block to spawn (this would make for some unpleasant regions). Palm trees would even have a very small chance of spawning in cold regions if there wasn't a rule to not allow that.


What can be expected in the future?

White flower and wild grass near a lake surrounded by oak trees, some with autumn leaves.



Environments have a huge purpose in shaping a region and will have an even larger purpose in the near future. Environments are planned to also determine the creatures that spawn, the resources that you'll find, and the weather that takes place.


Expect many different blocks and structures to be added. This can be different types of grasses, lava, ash blocks, different trees, mushroom trees, things that are completely made up, the possibilities are endless!


Aside from more content, there's still more work to be done with the existing system. There's a lot of tweaking that can be done to get the terrain to generate better looking regions. The colors/textures of some blocks need some work, and the tree structures as well.


To conclude this part of the terrain generation series I just want to recap some of the features that have been discussed. Fableforge's procedural terrain generation is meant to be very flexible to create diverse regions. It's meant to produce a deep sense of adventure and discovery. The goal is to have each region feel unique, even when you decide to create a whole new world!