# Terrain Provider

The **Terrain Provider** component connects a Unity `Terrain` object to the [FloraSystem](/scripts/system.md), enabling Flora to take over **tree** and **detail mesh** rendering.

> This component is typically added automatically when the [SceneSettings](/scripts/scene-settings.md) singleton is present and **Auto Register Terrains** is enabled.
>
> **Scope:** This page applies to Unity `Terrain` integration (terrain trees/details).\
> For non-Terrain workflows, use [Instance Container](/scripts/instance-container.md) or [Instance Renderer](/scripts/instance-renderer.md). See [Container Samples](/samples/container-samples.md).

***

## Trees

Tree instances are **loaded** from the terrain when a camera, and its far plane, are within distance of the terrain’s [`treeDistance`](https://docs.unity3d.com/ScriptReference/Terrain-treeDistance.html) value.

<figure><img src="/files/5shpYrLGpIZxRzT8nTaO" alt="Terrain tree distance UI"><figcaption></figcaption></figure>

***

## Details

Detail instances (e.g. grass, rocks, debris) are loaded when a camera, and its far plane, are within the terrain’s [`detailObjectDistance`](https://docs.unity3d.com/ScriptReference/Terrain-detailObjectDistance.html) range.

* When a detail cell goes **out of range**, it is **unloaded after 3 seconds**
* This helps reduce **GPU memory usage** in large terrain scenes

> ⚠️ For large environments, keep **detailObjectDistance** at a reasonable level to avoid unnecessary memory usage.

Unlike Unity’s built-in rendering system, Flora **supports detail meshes with LODGroups**.

* If Flora is disabled, Unity will fall back to its built-in rendering
* However, only the **first LOD mesh** will be used in that fallback path

<figure><img src="/files/Mg95slUuUdWvGTSHBEKS" alt="Detail mesh preview with LODs"><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://flora.magneticarcade.com/scripts/terrain-provider.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
