Terrain Generators

Modified on Wed, 27 Dec 2023 at 08:18 AM

Each World must have a Terrain Generator attached to the terrain generator field:



The terrain generator component is responsible for providing basic data about any world position like ground altitude, moisture and biome type.


The demo Earth world provided with Voxel Play contains a terrain generator that you can modify, duplicate or reuse:



You can also create a new terrain generator right-clicking on the Project Panel and selecting Create -> VoxelPlay -> Terrain Generators -> Default Terrain Generator:



This option will create an terrain generator based on the Default Terrain Generator algorithm provided by Voxel Play (see “Coding your own terrain generator” for instructions on how to create your own methods).


Select the Terrain Generator to see its properties or click “Expand/Collapse Generator Settings in the Voxel Play Environment inspector to see its properties:



The default generator uses a multi-step process to generate a terrain altitude from 0 to the maximum altitude defined by “Max Height” property.

  • You can also set the Sea Level (0..1 range relative to the Max Height). Setting it to 0 will disable any water in the world.
  • Sea Depth Multiplier is a value that multiplies the altitude below Sea Level.
  • Beach Width: increase this value to generate more shore voxels.
  • Moisture: choose a noise texture used to define the different moisture values for the world. Moisture Scale defines the frequency of sampling noise (increase to create bigger areas with same moisture).
  • Steps: define one or more operations that occurs in sequence to generate the altitude value. The demo scene includes the following steps:

Each step is defined by:

  • Operation type (the dropbox). The operation type defines what is done at this step. It could be a sample from a texture or a math operation on the previous value.
  • Depending on the operation type additional parameters appear. For example, in the case of sampling a value from a noise texture, it offers you to select the Frecuency and the output range (min-max). This way if the noise texture has values from 0 to 1 you can specify an output range of 0.5.. 0.8 meaning those values will be mapped in the new range.

Each step produces a result value which will be default input to the next step.


Available step operations are:


  • Sample Height Map Texture: reads a value from a heightmap texture (Voxel Play provides 3 noise textures inside Resources/Worlds/Earth/Noise folder, but you can provide your own heightmaps). Frecuency: the scale used to sample the texture. Min/Max: the output range. Sampled values are mapped to this range.
  • Sample Ridge Noise From Texture: same than Sample Height Map Texture but applies the following formula to the noise value:  2 * (0.5 - abs(0.5-value)). Produces more acute reliefs, usually to generate rivers (when inverted) or pointy mountains.
  • Sample Heightmap from Unity Terrain: same than Sample Height Map Texture but reads from the heightmap of an existing terrain in the scene. Note: if you want to recreate an existing terrain including vegetation and trees but with voxel style, check the Unity Terrain Generator instead.
  • Constant: outpus a constant value.
  • Copy: copies a result from any previous step.
  • Random: produces a random value in the 0-1 range.
  • Invert: inverts previous value. Equals to 1-value.
  • Beach Mask: useful to ensure no beaches occur on certain world areas. If the value from a chosen step is greater than certain threshold value then it will mask out any potential beach (shore voxel) on that position.
  • Add and Multiply: adds a number to the previous value and multiply the result by another number.
  • Multiply And Add: multiplies previous value by a number and add another number to the result.
  • Exponential: applies an exponential function to the previous value. Usually used to increase valleys and mountains shapes.
  • Threshold: checks a value for a minimum. If the value is equal or greater than the minimum, output that value plus an optional number. If the value is less than the minimum, replace it by a constant value.
  • Flatten or Raise: checks a value for a minimum. If the value is equal or greater than the minimum, multiply that value by a number. If the value is less than the minimum, output it as is.
  • Blend Additive: adds 2 previous values with custom weights. Equals to (value1 * weight1 + value2 * weight2).
  • Blend Multiply: multiplies 2 previous values.
  • Clamp: ensure a value falls between a given range. If a value is 0.3 and the desired range is 0.4..0.8, clamp will output 0.4. If the value is 0.9, clamp will output 0.8. If the value is between 0.4 and 0.8, Clamp won’t modify the value.
  • Select: filters values from a previous step by given a valid range. Any value outside the range will be replaced by a constant.
  • Fill: replaces any value from a previous step in the given range by a constant.
  • Island: this operator will reduce the height value based on the distance to 0,0,0 position.
  • Test: checks if a previous value falls inside a given range. If it does, test will output 1. If not, it will output 0.



Feel free to experiment with steps and see the effect on the world. We recommend enabling the Render In Editor toggle so you can test the changes inside the Scene View.



About Biomes


The terrain generator is responsible for producing an altitude and moisture (humidity) value for any world position. Using this altitude and moisture, Voxel Play looks up the matching biome and picks the appropriate voxel definition for the surface and the underground voxels.


Check the biome definitions page for more details about how to define biomes based on altitude and moisture ranges.



Complete world & terrain generation tutorial







Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article