Why is the TerrainData.SetHeight so slow?


  • I want to make our terrain tools run at an interactive speed.


You have implemented some in-house terrain forming tools, but applying any changes to a terrain results in a dramatic drop in performance making them barely usable.


When creating you own terrain editing tools, TerrainData.SetHeights is naturally slower. This is because it needs to recalculate all the terrain LOD information, which is done on every call to SetHeights.

A patch was released for 5.2.0a3 where the SetHeightsDelayedLOD API was introduced to improve the speed at which TerrainData.SetHeights recalculates the LOD information.

In this patch release, the Editor uses two internal functions:

  • SetHeightDelayedLOD()
  • ApplyDelayedHeightmapModification()

With SetHeightDelayedLOD(), the LOD calculation can be skipped or delayed while editing, and is triggered once the mouse button is released.

In interactive editing scenarios, it is advised to call TerrainData.SetHeightsDelayLOD instead, followed by Terrain.ApplyDelayedHeightmapModification when the user completes an editing action.

More Information

For more information on TerrainData.SetHeights see this document here.

Go here to download the relevant patch where this SetHeightsDelayedLOD API has been implemented.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


  • 0
    Ken Braybrook

    One way around this problem is to use a plain mesh and do your own heightMap changes by calculating the heightmap data then applying it to the mesh.  I only advise doing this if you know how to program well enough to handle terrain decoration and modification on your own.

Please sign in to leave a comment.