
Threading made possible because of Logyrac
- 📈 Kickstart any voxel project for Unity
- 📖 Learn how voxel-based games work
- 📝 Contribute your voxel knowledge
There a couple of things you need to set up before a voxel world is created:
- Create an empty Game Object. You can call it anything, but something like GenerationManager can help with organization
- Add the
Generation
script to the empty object - Set up the
Block List
,Contintalness To Height
spline,Terrain Material
, specify whether or not you want toUse Greedy Meshing
(it is recommended), and then add theMain Block
,Underwater Block
,Stone Block
, andDirt Block
- The terrain material,
TerrainMat
is in theShaders
folder
- The terrain material,
- (Optional) Input whatever you want for your seed in the
Input Seed
field! This can be a int or a string. A float will be converted to a string.- If left blank, a random seed will be generated
- Create an empty Game Object. You can call it anything, but something like AsyncHelper can help with organization
- Add the
AsyncHelper
script to the empty object (Assets > Voxels > Scripts > Dispactcher)
In the Blocks
folder, right click, Create > VoxelStuff > BlockList you can name it whatever you like (Recommended: BlockList)
Now you can add block types to the Blocks
field in the block list!
In the Blocks
folder, right click, Create > VoxelStuff > Block you can name it whatever you like (Recommended: BlockName)
As of right now, there is only one field: Vertex Color
. This is the color the voxel will appear in the world
- Create a
GrassBlock
,SandBlock
,StoneBlock
, andDirtBlock
. Make sure to place these in the coresponding fields in the Generation inspector
Fun fact: this method of generating terrain is inspired by the Minecraft way of generating terrain!
This entire project was inspired by the following talk by Minecraft developer Henrik Kniberg:
In your GenerationManager (or the object in which you placed the Generation
script), you can manipulate the Contintalness To Height
spline to represent how terrain height will respond to "contintalness" (the perlin noise values)
- The spline has x-values going from 0-10, and y-values going from 0-1 (during generation, it becomes 0-100)
- Imagine the x-value of 0 as the bottom of the ocean
- y = 20 is coastline
In the Spline
script (Assets > Voxels > Scripts) you can edit the "step" of the spline. A smaller spline value means smoother terrain. If you don't like the default look of the terrain changing height by gradually "stepping," you can change the line private const float STEP = 0.1f;
to be below the default value of 0.1f.
Below is a good example for a Contentalness to Height spline:
As you can see, we have flat values from x = 0
to x = ~4.9
representing the ocean floor. The sharp increase in height from x = ~4.9
to x = 5
is the transition to coast.