New: Nature Renderer 2021

Render vast amounts of detailed vegetation on your terrain.

Learn more
This page may not work correctly inside the Unity editor. Open in browser

Place Objects

Nature Renderer is designed to work in both edit mode and at runtime, so it is possible to edit terrain details at runtime if you need to make permanent changes to your terrain.

How to edit the terrain

  1. Edit Unity's terrain data using TerrainData.SetDetailLayer.
  2. Nature Renderer will automatically find the modified part of your terrain and rebuild the internal buffers for that area. Rebuilding is done on a separate worker thread and can take a few frames to finish. During this time the old terrain data is still shown.

Manual Refreshing

Nature Renderer automatically refreshes its internal data when the terrain is modified. However, this may cause performance issues if your code does a lot of modifications to the terrain. If you need to do a lot of modifications then it is recommended to disable "Auto Refresh Terrain at Runtime" in the Advanced section of the Nature Renderer component. Then, you can manually refresh the internal data after making one or multiple modifications:

using VisualDesignCafe.Rendering.Nature;

    .Refresh( NatureRenderer.RefreshFlags.DetailLayers );


You can specify which data to refresh using the RefreshFlags. Multiple flags can be combined in case you made multiple modifications to the terrain.

For example: RefreshFlags.DetailLayers | RefreshFlags.HeightMap


using UnityEngine;
using VisualDesignCafe.Rendering.Nature;

public class ExampleClass : MonoBehaviour
    void SetDensity( Terrain t, int layer, int density )
        // Get all of layer zero.
        int[,] map = 
            layer );
        // Set the density for each pixel in the detail map...
        for (int y = 0; y < t.terrainData.detailHeight; y++)
            for (int x = 0; x < t.terrainData.detailWidth; x++)
                map[x, y] = density;
        // Assign the modified map back.
        t.terrainData.SetDetailLayer(0, 0, layer, map);
        // Update Nature Renderer (optional)
            .Refresh( NatureRenderer.RefreshFlags.DetailLayers );



Was this article helpful?
3 out of 4 found this helpful