A terrain system for Unity that you can build on to create your own games
Compatible for Unity 2021.3.0f1 upwards
Published by Lizoft
MC Terrain is an implementation of the marching cubes method to generate terrain from 3D noise. Because the terrain is generated as a 3D array of cubes it is possible for the player to interact with the terrain allowing it to be raised and lowered. After the terrain has been altered, the code simply marches the cubes again and the updated terrain is displayed.
The project includes a procedural endless terrain implementation, achieved by dividing the terrain into 16x16 chunks that are 100 cubes high, and as the player is moved across the terrain, chunks are created and hidden as needed to keep the player in the centre of the play area. The play area is described by a 512 x 512 biome map texture. The texture wraps on both axes allowing for a potentially infinite play area.
The project also includes a biome implementation allowing eleven different biomes to be described, each populated by different terrain textures, scenery and vegetation.
Please note that no scenery items except for the grass are included with the package, and only a very basic player capsule is included.
• Marching cubes terrain generation
• Player can raise and lower terrain
• Endless map scrolling
• Everything procedurally generated from a single seed
• 11 Biomes, set up using scriptable objects
• Option to use your own biome and height maps
• Different trees, bushes, rocks, stones and grass can be set for each biome type (no scenery prefabs are included)
• GPU Instanced grass
• Water implementation (no water shaders are included)
MC Terrain can be installed and running with just a couple of mouse clicks!
Once MC Terrain is running, the first thing to do it to replace the TempPlayer GameObject with a fully featured Player Controller. You can use either Third Person or First Person Controllers.
MC Terrain can use the Standard Render Pipeline, the Universal Render Pipeline or the High Definition Render Pipeline.
Biomes are set up using Scriptable Objects, and there are settings to change the look and feel of the biomes.
Terrain is generated using 3D noise and there are a number of settings to change the look of the terrain.
The terrain can be raised and lowered in-game allowing the player to change the landscape and dig out tunnels and caves.
Each biome can have different scenery objects, with settings to choose how the scenery is displayed.
There are a selection of Dev Mode Options available for working with MC Terrain.
To get a different texture on the sides of the terrain (eg. rock) compared to the flatter areas (eg. grass) a Triplanar shader is used. Triplanar is a method of generating UVs and sampling a texture by projecting in world space. The input Texture is sampled 3 times, once in each of the world X, Y and Z axes. The resulting information is planar projected onto the model, blended by the normal, or surface angle, with the flatter areas using the grass texture and the steeper areas using the rock texture.
For the Standard Render Pipeline I referenced an excellent article found here:
https://catlikecoding.com/unity/tutorials/advanced-rendering/triplanar-mapping/
For both the Universal Render Pipeline and the High Definition Render Pipeline I made use of Shadergraph and its Triplanar node, and used the Dot Product of the Normal Vector to lerp between the two texture inputs as can be seen in the image. The image shows the High Definition Render Pipeline version. The only difference between the two versions of the shader is the Active Targets setting, which I changed to URP for the Universal Render Pipeline version.