Terrain Generation

From Vintage Story Wiki
Jump to navigation Jump to search
Other languages:
English • ‎русский

The terrain generation system is extremely complex and intricate.

"Terrain Generation" is the term for all the parts of the world that are created by the game that are blocks. This includes, but is not limited to, soil, mountains, lakes, trees, and ruins.

Stages of terrain generation

The following steps are an overview, the next section will have a much more in depth explanation of these stages.

  1. generate noise maps for various properties.
  2. landforms, these are chosen based on a landform noise map.
  3. rock strata, this is the stage where the type of rock in a region is chosen partly based on a geologic province noise map.
  4. caves, chunks are populated with caves.
  5. block layers, layers placed on top of the current ground, e.g. soil, snow, and grass.
  6. deposits, ores and other things in the stone are placed.
  7. structures, this adds ruins, trader carts, treasure chests, and more.
  8. ponds, bodies of water.
  9. vegetation and patches, plants that are randomly found in groups, cattails, horsetail, and flowers. It also adds trees.
  10. finalize, this finishes the process, processing light in a chunk, spawning animals, and adding snow.

Technical

Each stage is defined in the Survival base mod.

Noise maps

VS utilizes three methods for generating noise: weighted octave, Perlin, and normalized simplex noise. Each one behaves differently. In total, seven [1] noise maps are created at this stage.

  • Climate
  • Flower
  • Bush
  • Forest
  • Beach
  • Geologic province
  • Landform

These maps are utilized by later stages to provide randomness to terrain.

Landforms

These are the shapes the land takes. There are many different landforms that can generate and some utilize more than one noise map, mostly the climate map. Each landform's properties are defined in the game assets. There are several optional properties, but all landforms must specify:

  • Octaves
  • Octave thresholds
  • Terrain Y key positions
  • Terrain Y key thresholds

Octaves defines how rough or smooth terrain is.

Rock strata

Rocks are generated in layers and those layers are grouped by their type: sedimentary, metamorphic and igneous.

Sedimentary group doesn't have to be generated. If it does, sedimentary stones lie above all metamorphic and igneous stones.

Metamorphic group doesn't have to be generated. If it does, metamorphic stones rest below all sedimentary layers and above all igneous layers.

Igneous group will always be generated. Igneous stones always start at the mantle, at the bottom of the map, and stretch upwards until it reaches metamorphic or sedimentary layers, or the surface.

Certain kinds of rocks have special spawning rules.

  • Basalt, despite being an igneous stone, can be generated above any layer, including sedimentary and metamorphic stones.
  • Halite spawns in underground domes of substantial size.
  • Marble spawns in veins in phyllite and slate.
  • Obsidian spawns in veins in basalt.
  • Suevite is found only in craters, surrounding meteoric iron veins.

Caves

Caves

Block layers

Layers of blocks.

Deposits

Deposits are handled in GenDeposits.cs in the Survival Mod. The code for deposits handles more than just ores in rocks. There are many steps in the process of generating ores.

  1. All assets in worldgen/deposits/ are loaded and parsed.
    1. The generator goes over all deposits and adds them to a list.
    2. If there are any child deposits, they are registered.
  2. A deposit shape distortion map is created. This is used when initializing deposits.
  3. The generator goes over all registered deposits.
    1. Each deposit variant is initialized with a random seed and the deposit shape distortion map. This init process is the same for all deposits and is used only to simplify the code.
    2. If the deposit variant uses an ore map, one is created for it. Each kind of deposit gets its own ore map.
    3. If there are any child deposits that also use an ore map, one is created for the child deposit.

This is the end of what is done in GenDeposits. When a new world region is generated, GenDeposits calls .OnMapRegionGen on each deposit variant.

  1. Region generation begins by updating the vertical distortion ore maps for the region.
  2. Each deposit variant then generates ore in the region.

GenDeposits.OnMapRegionGen is relatively simple because most of the generation work is given to each variant. What actually happens when a variant generates a region is dependent on which ore generator is used, of which there are several.

Structures

Trader carts, ruins, vugs.

Ponds

Vegetation and patches

Vanilla Game Content
Terrain Blocks

Rawclay blue.pngClay Grid Gravel Granite.pngGravel Peat.pngPeat Grid Rock granite.pngRock Grid Granite sand.pngSand Grid Barren low fertility soil.pngSoil

Construction Blocks

Claybricks-blue.pngCeramic Blocks Glass-plain.pngGlass Planks-oak.pngPlanks Grid Diagonal logs plaster.pngPlaster Grid Cob.pngSoil Blocks Grid Polished Granite.pngStone Blocks Grid Stone path.pngPath

Functional Blocks

Grid Barrel.pngBarrel Grid Woodbucket.pngWooden Bucket Bed-wood-head-north.pngBed Chest-east.pngContainers Firepit lit.pngFirepit Forge.pngForge Grid Loot Vessel.pngCracked Vessels Grid Ore blasting bomb.pngOre blasting bomb Grid Large trough.pngTrough

Decorative Blocks

Grid Painting.pngPainting Mediumcarpet-turqoise-ns.pngCarpets Bookshelves-ns.pngBookshelves Flowerpot-earthern-empty.pngFlowerpots Agedwallpaperplanks-green-east.pngWallpapers Salvation.pngTapestry

Metal Working

Grid Copper anvil.pngAnvil Bloomery.pngBloomery Grid Crucible burned.pngCrucible Forge.pngForge Grid Tin bronze helve hammer.pngHelve_hammer Ingot Mold Burned.pngMolds Grid Copper Ingot.pngMetal Gem-emerald-rough.pngGemstone

Tools & Weapons

Grid Copper axe.pngAxe Bow-simple.pngBow Grid Copper Chisel.pngChisel Grid copper cleaver.pngCleaver Grid Wooden club.pngClub Grid Copper hammer.pngHammer Hoe-copper.pngHoe Knife-copper.pngKnife Pickaxe-copper.pngPickaxe Grid Copper prospecting pick.pngProspecting Pick Grid Copper saw.pngSaw Scythe-copper.pngScythe Grid Copper shears.pngShears Grid Crude Square Shield.pngShield Shovel-copper.pngShovel Grid Copper spear.pngSpear Sword-copper.pngSword

Equipment

Armor-body-brigandine-iron.pngArmor Clothes-upperbody-lackey-shirt.pngClothes Grid Backpack.pngBags

Craftable Resources

Grid Oak board.pngBoards Charcoal.pngCharcoal Coke.pngCoke Grid Firewood.pngFirewood Grid Copper Ingot.pngIngots Grid Raw hide.pngLeather Flaxtwine.pngFlax

Plants

Berrybush red currant ripe.pngBerries Grid mushroom bolete.pngMushrooms Grid Cattail tops.pngCooper's Reed (Cattail) Flower-californiapoppy.pngFlowers Tallgrass-tall.pngGrass Tallfern.pngOther Plants Sapling-oak.pngTrees Sapling-oak.pngFruit Trees Flax.pngWild Foods

Mobs

Bear-male-polar.pngBear BeeMob.pngBees Creature-bell-normal.pngBell Bighorn.pngBighorn sheep Rooster.pngChicken Normal Drifter.pngDrifter Creature-fox-male.pngFox Hare-male-lightbrown.pngHare Hyena.pngHyena Locust.pngLocust Raccoon.pngRaccoon Pig.pngWild Pig Wolf.pngWolf

Mechanics

Pig.pngAnimal Husbandry Grid Empty skep.pngBeekeeping Grid Crucible burned.pngCasting Grid Blue clay.pngClay Forming Sword-copper.pngCombat Hoe-copper.pngFarming Bread-spelt.pngCooking Bone.pngHealth Flax.pngSatiety Grid Flint arrow head.pngKnapping Grid Angled Gears.pngMechanical Power Pickaxe-copper.pngMining Grid Copper anvil.pngSmithing Creature-humanoid-trader-treasurehunter.pngTrading Gear-temporal.pngTemporal Stability Grid Copper hammer.pngSteel Making

Guides

Grid Lore Book.pngCrafting Recipes Charcoal.pngFuel Grid Raw hide.pngLeather Working Torch.pngLight sources Grid Copper Chunk.pngOre Deposits Grid Ruins.pngRuins Grid Lore Scroll.pngStarter Guide Berrybush blueberry ripe.pngWorld Generation