Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Terrain

The Terrain component renders the terrain.
Read time 10 minutesLast updated 2 days ago

Definition

public sealed class Terrain : Behaviour

Properties

Property

Description

allowAutoConnectSpecifies if the terrain tile will be automatically connected to adjacent tiles.
bakeLightProbesForTreesWhether to bake an array of internal light probes for Tree Editor trees (Editor only).
basemapDistanceHeightmap patches beyond basemap distance will use a precomputed low res basemap.
bottomNeighborTerrain bottom neighbor.
collectDetailPatchesCollect detail patches from memory.
deringLightProbesForTreesRemoves ringing from light probes on Tree Editor trees (Editor only).
detailObjectDensityDensity of detail objects.
detailObjectDistanceDetail objects will be displayed up to this distance.
drawHeightmapIndicates whether Unity draws the Terrain geometry itself.
drawInstancedSet to true to enable the terrain instance renderer. The default value is false.
drawTreesAndFoliageSpecify if terrain trees and details should be drawn. If disabled, this will also disable updates to renderer positions for trees and details. Tree and detail renderer positions will update again once this setting is re-enabled.
editorRenderFlagsControls what part of the terrain should be rendered.
enableHeightmapLODFrustumCullingControls frustum culling for the terrain heightmap LOD system.
enableHeightmapRayTracingWhen this options is enabled, Terrain heightmap geometries will be added in acceleration structures used for Ray Tracing.
groupingIDGrouping ID for auto connect.
heightmapMaximumLODLimits the Terrain's maximum rendering resolution.
heightmapMinimumLODSimplificationLimits how simplified the rendered terrain can be.
heightmapPixelErrorAn approximation of how many pixels the terrain will pop in the worst case when switching lod.
ignoreQualitySettingsWhen enabled, the terrain ignores the terrain overrides set in the QualitySettings.
keepUnusedRenderingResourcesDefines whether Unity frees per-Camera rendering resources for the Terrain when those resources aren't in use after a certain number of frames.
leftNeighborThe Terrain tile to the left, which is in the negative X direction.
lightmapIndexThe index of the baked lightmap applied to this terrain.
lightmapScaleOffsetThe UV scale & offset used for a baked lightmap.
materialTemplateThe custom material Unity uses to render the Terrain.
normalmapTextureReturns the normal map texture computed from sampling the heightmap. It is only used when terrain is rendered using instancing.
patchBoundsMultiplierSet the terrain bounding box scale.
preserveTreePrototypeLayersAllows you to specify how Unity chooses the layer for tree instances.
reflectionProbeUsageHow reflection probes are used for terrain. See ReflectionProbeUsage.
renderingLayerMaskDetermines which rendering layers the Terrain renderer lives on.
rightNeighborThe Terrain tile to the left, which is in the positive X direction.
shadowCastingModeAllows you to set the shadow casting mode for the terrain.
splatBaseMaterialReturns the material used to render the terrain splatmap.
terrainDataThe Terrain Data that stores heightmaps, terrain textures, detail meshes and trees.
topNeighborTerrain top neighbor.
treeBillboardDistanceDistance from the camera where trees will be rendered as billboards only.
treeCrossFadeLengthTotal distance delta that trees will use to transition from billboard orientation to mesh orientation.
treeDistanceThe maximum distance at which trees are rendered.
treeLODBiasMultiplierThe multiplier to the current LOD bias used for rendering LOD trees (i.e. SpeedTree trees).
treeMaximumFullLODCountMaximum number of trees rendered at full LOD.
treeMotionVectorModeOverrideThe motion vector rendering mode for all SpeedTree models painted on the terrain.

Static Properties

Property

Description

activeTerrainThe active Terrain. This is a convenient function to get to the main Terrain in the Scene.
activeTerrainsThe active terrains in the Scene.
compressedHolesFormatGraphics format of the Terrain holes Texture when it is compressed.
compressedHolesTextureFormatTexture format of the Terrain holes Texture when it is compressed.
heightmapFormatGraphics format of the Terrain heightmap.
heightmapRenderTextureFormatRenderTextureFormat of the terrain heightmap.
holesFormatGraphics format of the Terrain holes Texture when it is not compressed.
holesRenderTextureFormatRender texture format of the Terrain holes Texture.
normalmapFormatGraphics format of the Terrain normal map texture.
normalmapRenderTextureFormatRender texture format of the Terrain normal map texture.
normalmapTextureFormatTexture format of the Terrain normal map texture.

Methods

Method

Description

AddTreeInstanceAdds a tree instance to the terrain.
FlushFlushes any change done in the terrain so it takes effect.
GetClosestReflectionProbesFills the list with reflection probes whose AABB intersects with terrain's AABB. Their weights are also provided. Weight shows how much influence the probe has on the terrain, and is used when the blending between multiple reflection probes occurs.
GetKeepUnusedCameraRenderingResourcesEach Camera has its own
KeepUnusedRenderingResources
setting, which is
false
by default. Unity uses this per-Camera setting in combination with the Terrain's overall
KeepUnusedRenderingResources
setting. If either setting is
true
, Unity preserves all rendering resources regardless of how long they've remained unused.
GetPositionGet the world space position of the terrain.
GetSplatMaterialPropertyBlockGet the previously set splat material properties by copying to the
dest
MaterialPropertyBlock object.
SampleHeightSamples the height at the given position defined in world space, relative to the Terrain space.
SetKeepUnusedCameraRenderingResourcesDefines whether Unity cleans up rendering resources for a given Camera during garbage collection.
SetNeighborsLets you set up the connection between neighboring Terrain tiles. This ensures LOD matches up on neighboring Terrain tiles.
SetSplatMaterialPropertyBlockSet the additional material properties when rendering the terrain heightmap using the splat material.

Static Methods

Method

Description

CreateTerrainGameObjectCreates a Terrain including collider from TerrainData.
GetActiveTerrainsPopulates a List of Terrains with the active Terrains in the Scene.
SetConnectivityDirtyMarks the current connectivity status as invalid.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.