Biomes and Decorations: Improve and fix errors

This commit is contained in:
rubenwardy 2019-08-14 15:13:18 +01:00
parent a465572ae5
commit 2b75ac00da
4 changed files with 89 additions and 81 deletions

View File

@ -4,3 +4,6 @@ metatable
singleplayer singleplayer
Staticdata Staticdata
biomes
Voronoi

View File

@ -1,5 +1,6 @@
--- ---
title: Biomes and Decorations title: Biomes and Decorations
author: Shara
layout: default layout: default
root: ../.. root: ../..
idx: 6.1 idx: 6.1
@ -13,32 +14,36 @@ interesting and varied in-game environment. This chapter teaches you how to
register biomes, how to control biome distribution, and how to place decorations in biomes. register biomes, how to control biome distribution, and how to place decorations in biomes.
- [What are Biomes?](#what-are-biomes) - [What are Biomes?](#what-are-biomes)
- [Biome Placement](#biome-placement)
- [Heat and Humidity](#heat-and-humidity) - [Heat and Humidity](#heat-and-humidity)
- [Biome Locations](#biome-locations) - [Visualising Boundaries using Voronoi Diagrams](#visualising-boundaries-using-voronoi-diagrams)
- [Visualising Biome Boundaries](#visualising-biome-boundaries) - [Creating a Voronoi Diagram using Geogebra](#creating-a-voronoi-diagram-using-geogebra)
- [Mapgen Aliases](#mapgen-aliases)
- [Registering a Biome](#registering-a-biome) - [Registering a Biome](#registering-a-biome)
- [What are Decorations?](#what-are-decorations) - [What are Decorations?](#what-are-decorations)
- [Registering a Simple Decoration](#registering-a-simple-decoration) - [Registering a Simple Decoration](#registering-a-simple-decoration)
- [Registering a Schematic Decoration](#registering-a-schematic-decoration) - [Registering a Schematic Decoration](#registering-a-schematic-decoration)
- [Mapgen Aliases](#mapgen-aliases)
## What are Biomes? ## What are Biomes?
A Minetest biome is a specific in-game environment. When registering biomes you A Minetest biome is a specific in-game environment. When registering biomes, you
can determine the types of nodes that appear in them during map generation. can determine the types of nodes that appear in them during map generation.
Some of the most common types of node that may vary between biomes include: Some of the most common types of node that may vary between biomes include:
* Top node: This is the node most commonly found on the surface. A well-known * Top node: This is the node most commonly found on the surface. A well-known
example would be Dirt with Grass from Minetest Game. example would be "Dirt with Grass" from Minetest Game.
* Filler node: This is the layer immediately beneath the top node. * Filler node: This is the layer immediately beneath the top node.
In biomes with grass, it will often be dirt. In biomes with grass, it will often be dirt.
* Stone node: This is the node you most commonly see underground. * Stone node: This is the node you most commonly see underground.
* Water node: This is usually a liquid and will be the node that appears * Water node: This is usually a liquid and will be the node that appears
where you expect bodies of water. Other types of node can also vary between where you would expect bodies of water.
biomes, providing an opportunity to create vastly different environments
within the same game.
## Heat and Humidity Other types of node can also vary between biomes, providing an opportunity
to create vastly different environments within the same game.
## Biome Placement
### Heat and Humidity
It is not enough to simply register a biome; you must also decide where it can It is not enough to simply register a biome; you must also decide where it can
occur in game. This is done by assigning a heat and a humidity value to each biome. occur in game. This is done by assigning a heat and a humidity value to each biome.
@ -48,8 +53,6 @@ be neighbours to each other. Poor decisions could result in what is meant to
be a hot desert sharing a border with a glacier, and other improbable be a hot desert sharing a border with a glacier, and other improbable
combinations which you may prefer to avoid. combinations which you may prefer to avoid.
### Biome Locations
In game, heat and humidity values at any point of the map will usually be between In game, heat and humidity values at any point of the map will usually be between
0 and 100. The values gradually change, increasing or decreasing as you move 0 and 100. The values gradually change, increasing or decreasing as you move
around the map. The biome at any given point will be determined by which of the around the map. The biome at any given point will be determined by which of the
@ -63,30 +66,37 @@ biomes environment. For example:
* A snowy forest might have low heat and a medium humidity value. * A snowy forest might have low heat and a medium humidity value.
* A swamp biome would generally have high humidity. * A swamp biome would generally have high humidity.
* *
In practice this means that, as long as you have a diverse range of biomes, you In practice, this means that, as long as you have a diverse range of biomes, you
are likely to find that the biomes which border each other form a logical progression. are likely to find that the biomes which border each other form a logical progression.
## Visualising Biome Boundaries ### Visualising Boundaries using Voronoi Diagrams
<figure class="right_image"> <figure class="right_image">
<img src="https://via.placeholder.com/300x200/" alt="Vernoi"> <img src="{{ page.root }}/static/biomes_voronoi.png" alt="Vernoi">
<figcaption> <figcaption>
Voronoi diagram Voronoi diagram, showing the closest point.
<span class="credit">By <a href="https://en.wikipedia.org/wiki/Voronoi_diagram#/media/File:Euclidean_Voronoi_diagram.svg">Balu Ertl</a>, CC BY-SA 4.0.</span>
</figcaption> </figcaption>
</figure> </figure>
Visualising Biome Boundaries Fine tuning heat and humidity values for biomes is Fine-tuning heat and humidity values for biomes is
easier if you can visualise the relationship between the biomes you are using. easier if you can visualise the relationship between the biomes you are using.
This is most important if you are creating a full set of your own biomes, but This is most important if you are creating a full set of your own biomes, but
can also be helpful if you are adding a biome to an existing set. can also be helpful if you are adding a biome to an existing set.
The simplest way to visualise which biomes may share borders with one another The simplest way to visualise which biomes may share borders is to create a
is to create a Voronoi diagram, which can be used to show which of a number of Voronoi diagram, which can be used to show which point on a 2-dimensional
points on a 2-dimensional diagram any given position is closest to. diagram any given position is closest to.
To do this, mark a point for each biome based on heat and humidity values, A Voronoi diagram can reveal where biomes that should border each other do not,
and where biomes that should not border each other do. It can also give a
general insight into how common biomes will be in-game, with larger and more
central biomes being more common than smaller biomes or biomes that are located
on the outer edge of the diagram.
This is done by marking a point for each biome based on heat and humidity values,
where the x-axis is heat and the y-axis is humidity. The diagram is then where the x-axis is heat and the y-axis is humidity. The diagram is then
divided into areas, so that every position in a given area is closer to the divided into areas, such that every position in a given area is closer to the
point inside that area than it is to any other point on the diagram. point inside that area than it is to any other point on the diagram.
Each area represents a biome. If two areas share a border, the biomes they Each area represents a biome. If two areas share a border, the biomes they
@ -94,36 +104,25 @@ represent in-game can be located next to each other. The length of the border
shared between two areas, compared to the length shared with other areas, will shared between two areas, compared to the length shared with other areas, will
tell you how frequently two biomes are likely to be found next to each other. tell you how frequently two biomes are likely to be found next to each other.
A Voronoi diagram can reveal: ### Creating a Voronoi Diagram using Geogebra
* Where biomes that should border each other do not. As well as drawing them by hand, you can also create Voronoi diagrams using
* Where biomes that should not border each other do. programs such as [Geogebra](https://www.geogebra.org).
It can also give a general insight into how common biomes will be in-game, with 1. Create points by selecting the point tool in the toolbar (icon is a point with 'A'),
larger and more central biomes being more common than smaller biomes and biomes and then clicking the chart. You can drag points around or explicitly set their
that are located on the outer edge of the diagram. position in the left sidebar. You should also give each point a label, to make things clearer.
1. Next, create the voronoi by entering the following function into the
input box in the left sidebar:
## Mapgen Aliases ```cpp
Voronoi({ A, B, C, D, E })
Existing games should already include suitable mapgen aliases, so you only need
to consider registering mapgen aliases of your own if you are making your own game.
Mapgen aliases provide information to the core mapgen, and can be registered in the form:
```lua
minetest.register_alias("mapgen_stone", "base:smoke_stone")
``` ```
At a minimum you should register: Where the each point is inside the curly brackets, separated by commas. You should now
* mapgen_stone 3. Profit! You should now have a voronoi diagram with all draggable points.
* mapgen_water_source
* mapgen_river_water_source
If you are not defining cave liquid nodes for all biomes, you should also register:
* mapgen_lava_source
## Registering a Biome ## Registering a Biome
@ -132,7 +131,7 @@ The following code registers a simple biome named grasslands biome:
```lua ```lua
minetest.register_biome({ minetest.register_biome({
name = grasslands, name = "grasslands",
node_top = "default:dirt_with_grass", node_top = "default:dirt_with_grass",
depth_top = 1, depth_top = 1,
node_filler = "default:dirt", node_filler = "default:dirt",
@ -146,53 +145,31 @@ minetest.register_biome({
This biome has one layer of Dirt with Grass nodes on the surface, and three layers This biome has one layer of Dirt with Grass nodes on the surface, and three layers
of Dirt nodes beneath this. It does not specify a stone node, so the node defined of Dirt nodes beneath this. It does not specify a stone node, so the node defined
in the mapgen alias registration for mapgen_stone will be present underneath the dirt. in the mapgen alias registration for `mapgen_stone` will be present underneath the dirt.
There are many options when registering a biome. The following can be included in There are many options when registering a biome, and these are documented
the registration: in the [Minetest Lua API Reference](https://minetest.gitlab.io/minetest/definition-tables/#biome-definition),
as always.
* name: The biomes name. You dont need to define every option for every biome you create, but in some cases failure
* node_dust: A layer of this node is placed after everything else. It is often used to add snow. to define either a specific option, or a suitable mapgen alias, can result in map generation errors.
* node_top: Type of node on the surface, but underneath node_dust.
* depth_top: Number of nodes deep the surface layer is.
* node_filler: Type of node directly under the surface layer.
* depth_filler: Number of nodes deep the filler layer is.
* node_stone: Type of node under the filler layer, extending down to y_min.
* node_water_top: Type of node appearing above surface water. It is often used to add ice.
* depth_water_top: Number of nodes deep the water top layer is.
* node_water: Type of node in surface level bodies of liquid.
* node_river_water: Type of node that appears in rivers. Note that this is not used for all mapgens available in the Minetest engine.
* node_riverbed: Type of node in riverbeds.
* depth_riverbed: Number of nodes deep the riverbed layer is.
* node_cave_liquid: Type of node in underground cave liquid.
* node_dungeon: Type of node used in underground dungeon walls.
* node_dungeon_alt: Alternative type of node used in dungeon walls.
* node_dungeon_stair: Stairs node used in dungeons.
* vertical_blend: Number of nodes above y_max over which the biome will blend with the next biome. This can be used to prevent abrupt biome changes.
* y_max: Maximum height of the biome.
* y_min: Minimum height of the biome.
* heat_point: Heat value for the biome.
* humidity_point: Humidity value for the biome
You dont need to define every option for every biome you, but in some cases failure
to define eithe a specific option, or a suitable mapgen alias, can result in map generation errors.
## What are Decorations? ## What are Decorations?
Decorations are either nodes or schematics that can be placed on the map at mapgen. Decorations are either nodes or schematics that can be placed on the map at mapgen.
Some common examples include flowers, bushes and trees. Other more creative uses Some common examples include flowers, bushes, and trees. Other more creative uses
may include hanging icicles or stalagmites in caves, underground crystal formations may include hanging icicles or stalagmites in caves, underground crystal formations,
or even the placement of small buildings. or even the placement of small buildings.
Decorations can be restricted to specific biomes, by height, or by which nodes Decorations can be restricted to specific biomes, by height, or by which nodes
they can be placed on They are often used to develop the environment of a biome they can be placed on. They are often used to develop the environment of a biome
by ensuring it has specific plants, trees or other features. by ensuring it has specific plants, trees or other features.
## Registering a Simple Decoration ## Registering a Simple Decoration
Simple decorations are used to place single node decorations on the map during Simple decorations are used to place single node decorations on the map during
map generation. You must specify the node that is to be placed as a decoration, map generation. You must specify the node that is to be placed as a decoration,
and details for where it can be placed, and how frequently. details for where it can be placed, and how frequently it occurs.
For example: For example:
@ -209,8 +186,8 @@ minetest.register_decoration({
}) })
``` ```
In this example, the node named plants:grass will be placed in the biome named In this example, the node named `plants:grass` will be placed in the biome named
grassy_plains on top of base:dirt_with_grass nodes, between the heights of y = 1 and y = 200. grassy_plains on top of `base:dirt_with_grass` nodes, between the heights of `y = 1` and `y = 200`.
The fill_ratio value determines how frequently the decoration appears, with higher The fill_ratio value determines how frequently the decoration appears, with higher
values up to 1 resulting in a great number of decorations being placed. It is possible values up to 1 resulting in a great number of decorations being placed. It is possible
@ -242,3 +219,25 @@ a path to a schematic, which in this case is stored in a dedicated schematic dir
This example also sets flags to center the placement of the schematic, and the rotation This example also sets flags to center the placement of the schematic, and the rotation
is set to random. The random rotation of schematics when they are placed as decorations is set to random. The random rotation of schematics when they are placed as decorations
helps introduce more variation when asymmetrical schematics are used. helps introduce more variation when asymmetrical schematics are used.
## Mapgen Aliases
Existing games should already include suitable mapgen aliases, so you only need
to consider registering mapgen aliases of your own if you are making your own game.
Mapgen aliases provide information to the core mapgen, and can be registered in the form:
```lua
minetest.register_alias("mapgen_stone", "base:smoke_stone")
```
At a minimum you should register:
* mapgen_stone
* mapgen_water_source
* mapgen_river_water_source
If you are not defining cave liquid nodes for all biomes, you should also register:
* mapgen_lava_source

View File

@ -10,10 +10,16 @@ img {
figure { figure {
padding: 0; padding: 0;
margin: 0; margin: 0;
.credit {
display: block;
font-size: 70%;
}
} }
.right_image { .right_image {
float: right; float: right;
text-align: right;
margin: 0 0 0 10px; margin: 0 0 0 10px;
padding: 0; padding: 0;
} }

BIN
static/biomes_voronoi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB