Skip to content

Series

Biomes and Vegetation on Voxel Terrain in Babylon.js

Turn the smooth voxel terrain into a living world: six biomes from a climate, each with its own ground and shape of land, lakes and shores, grass, flowers and reeds, trees grown branch by branch, forests to the horizon, wind in all of it, and an axe to fell the trees.

Advanced12 parts · about 7.5 h

Twelve parts that build on the smooth voxel terrain series and the building series. A climate of temperature and moisture picks between six biomes: meadow, broadleaf forest, conifer forest, tundra, savanna and desert. Each paints its own ground and shapes its own land, from dunes to snowy peaks, and a sea fills the low ground with lakes and shores. Then the land grows over: grass and small plants, scattered in the chunk workers and drawn by the tens of thousands, and trees that grow as skeletons of trunk, limbs and branches with sprays of leaves on them. Forests are planted tile by tile and reach the horizon as pictures of themselves, the wind moves everything, and an axe fells trees that fall as rigid bodies and lie as logs. Every texture is painted in code, and every part ends with a demo you can play right on the page, built from exactly the code it shows.

Start with part 1

Quest line

  1. Climate and biomesGive the voxel world a climate: temperature and moisture from noise, six biomes as points on a climate chart, soft borders between them, colder biomes up the mountains, a map view that paints the ground in the biomes' colors, and a key that flies you to the next biome.35 min
  2. Ground for every biomeGive every biome its own ground: five more textures painted in code, from forest litter to sand, blended by the biomes' weights in the shader, a tint for each biome's soil and rock, and snow that lies where it is cold instead of above a fixed height.30 min
  3. The shape of the landLet the biomes shape the land: each one a row of numbers for its plains, hills, mountains, rocky knolls and dunes, blended where biomes meet, so that the savanna lies flat, the desert rolls in dunes and the tundra is a high plateau, while the start stays as it was.25 min
  4. WaterFill the low land with water: a sea level, an ocean that the ground sinks into, lakes in the hollows, a water surface of rings with waves, a mirrored sky and foam, beaches of sand, a player that floats, and fog under water.40 min
  5. GrassGrow grass on the terrain: tufts scattered in the chunk workers on the ground as it really is, at places that stay put after every edit, drawn by the tens of thousands as instances of one small mesh, lush or dry by the biome, and only near the camera.45 min
  6. Flowers, ferns and reedsAdd eight kinds of small plants as sprites painted on a canvas and drawn on crossed cards: each biome lists its own, every kind grows in patches, reeds stand at the shore, mushrooms in caves, and all of them make way for the blocks you build.40 min
  7. Growing a treeGrow trees as skeletons: a trunk, limbs that reach for the outline of a crown, and branches off the limbs. Wrap them in tubes, paint four barks in code, and get six species, from oak to cactus, out of one set of numbers.45 min
  8. LeavesGive the trees their leaves: sprays painted on a canvas, set as cards along limbs and branches, tilted and rolled so that some always face you, with normals that point out of the crown, shade deep inside it, and light that shines through.35 min
  9. ForestsPlant the trees as forests: a rule that says for every cell of 6 m whether a tree stands there, of which species and how big, a worker that plants tile by tile, instanced drawing near the camera, trees that fade out in a grain, solid trunks, and shade on the ground.45 min
  10. Forests to the horizonCarry the forests on past the last mesh: take a picture of every tree model once, by drawing it into a texture, and let a card with that picture stand for each far tree, out to a kilometer. Beyond that, the far ground takes the color of the crowns.40 min
  11. WindSet everything that grows in motion with one wind: gusts that travel across the land as waves, written once in GLSL and shared by four vertex shaders. Grass bends, flowers nod, trees lean, bob and flutter, far cards sway with them, and a noise makes the wind heard.25 min
  12. Felling treesGive the player an axe. A tree that takes four blows leaves the forest and falls as a rigid body, smashes the blocks it hits, lands, sheds its leaves and lies as a solid log that the axe chops up. Trees whose ground is dug away fall too.40 min