# Terrain Painter

**`TerrainPainter`** - the component of TerraForge 2 designed for procedural terrain painting. It allows you to apply complex layer-based textures and effects to terrains dynamically, offering tools for creating detailed and customizable landscapes with minimal manual effort.

{% hint style="success" %}
Starting with [TerraForge 2 version 2.0.2](https://wiskered.gitbook.io/terraforge-documentation/how-it-works/pages/jW1RnClLoR3xDzgRX81W#v.-2.0.2.-terraforge-2), serialization bugs have been fixed and presets have been added
{% endhint %}

<figure><img src="/files/zcPscSgsp2MImmquihKa" alt=""><figcaption></figcaption></figure>

***

**`"Terrain Layers" Window`** - an array consisting of elements of the `Terrain Layer` type with additional modifiers. It also has separate buttons for creating and deleting individual layers. The order of the layers matters - the bottommost layer is considered the base layer and cannot have modifiers applied to it, as it is applied to the entire terrain area. Layers can be enabled and disabled using the `activity button` (shaped like an eye) next to each layer.

***

**`"Modifiers" Window`** - an array of modifiers for the active terrain layer. These are needed to adjust and add various rules for layer application on the terrain surface. To open the `Modifiers` window, select one of the layers in the "`Terrain Layers"` window.

<figure><img src="/files/FHBQ3z0nmRwadP1XELsS" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/G7nPX3gfrYYFqjEScAoi" alt=""><figcaption></figcaption></figure>

Each element in the modifiers array has various parameters:

* **`Activity`** - controls the influence of this modifier on the layer. It is toggled on and off using the `activity button` (shaped like an eye).
* **`Name`**  -  the name of the layer. It should never be changed. It serves as a tag for correct operation of the system, in particular for creating and loading presets.
* **`Blend Type`** - there are 3 types of blending: `Multiply`, `Add`, `Subtract, Min, Max`.
* **`Modifier Type`** - there are 6 types of modifiers: `Curvature`, `Direction`, `Height`, `Noise`, `Slope`, `Texture Mask`.

Let's go over the parameters for each `modifier type`:

**`Curvature`** - Adds the ability to use curvature-based effects for the selected layer.

* Parameters:

  * **`Min Max`** - The minimum and maximum curvature values for the modifier.
  * **`Radius`** - The radius of the curvature effect.
  * **`Min Falloff`** - The minimum falloff value for the curvature effect.
  * **`Max Falloff`** - The maximum falloff value for the curvature effect.

  <figure><img src="/files/FwDRCITBbo17t1RLXgJq" alt=""><figcaption></figcaption></figure>

**`Direction`** - Adds the ability to control the overlay direction of a particular layer.

* Parameters:
  * **`X Angle`** - The x angle of the directional modifier, ranging from 0 to 90.
  * **`Y Angle`** - The y angle of the directional modifier, ranging from 0 to 360.
  * **`Add Sun Direction`** - Whether the sun's direction is added to the angle calculations.
  * **`Levels`** - The levels for controlling the intensity of the directional effect, with a minimum of 0.

<figure><img src="/files/j2pTnRKaXt6ediR3nFbT" alt=""><figcaption></figcaption></figure>

**`Height`** - Adds the ability to adjust the minimum and maximum application heights with smooth transitions.

* Parameters:

  * **`Min`** - The minimum height value.
  * **`Min Falloff`** - The falloff value at the minimum height.
  * **`Max`** - The maximum height value.
  * **`Max Falloff`** - The falloff value at the maximum height.

  <figure><img src="/files/LoBlQQqEUwrB5A8kmBHi" alt=""><figcaption></figcaption></figure>

**`Noise`** - Adds the ability to create a mask for the layer in the form of noise with smooth edges, etc.

* Parameters:

  * **`Noise Type`** - there are 2 types of noise available: `Simplex` and `Gradient`.
  * **`Noise Scale`** - controls the noise scale.
  * **`Noise Offset`** - the offset of the current noise.
  * **`Levels`** - the levels of the noise represented as a range.

  <figure><img src="/files/pfPlYvY4bBIUGZLgzrlM" alt=""><figcaption></figcaption></figure>

**`Slope`** - Adds the ability to adjust the minimum and maximum application angles with smooth transitions.

* Parameters:

  * **`Min Max`** - The minimum and maximum slope angles to be affected by the modifier.
  * **`Min Falloff`** - The falloff range for the minimum slope.
  * **`Max Falloff`** - The falloff range for the maximum slope.

  <figure><img src="/files/yGmgpPgUl5i82LdPQNKu" alt=""><figcaption></figcaption></figure>

**`Texture Mask`** - Adds the ability to apply a texture mask based on the selected channel.

* Parameters:
  * **`Texture`** - The texture to be used as a mask on the terrain.
  * **`Channel`** - The channel of the texture to apply for the mask.
  * **`Span Terrains`** - Whether the mask should span across multiple terrains.
  * **`Tiling`** - The tiling factor for the mask texture.

<figure><img src="/files/opxeBkIzlPrzSeqgLwrG" alt=""><figcaption></figcaption></figure>

***

**Procedural Painting Application Window**:

* **`Auto Repaint`** - Automatically repaint the terrains if their heightmap is modified. When enabled, it adds a special component to the assigned terrains - `Terrain Change Listener`.
* **`"Apply Texture Layers"` Button** - Triggers a complete repaint operation. Typically needed if the terrain was modified in some way, yet no changes are made in the `TerrainPainter` component.

<figure><img src="/files/zxb24qjV6QoGBqNjqmiY" alt=""><figcaption></figcaption></figure>

***

**Window for saving and loading presets for TerrainPainter:**

**Save the Preset:** In the **Inspector** panel of the **`TerrainPainter`** component:

* Click the **Save Layer Settings Data** button.
* Choose a location and name for the preset file (saved as `LayerSettingsData`).

<figure><img src="/files/zxKSJQvrNdCDbAWSgiIk" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/pjrkqFAkkgKj0T6qdXEh" alt=""><figcaption></figcaption></figure>

#### **Loading a Preset via GUI**

1. **Prepare the Terrain Painter**\
   Ensure the **TerrainPainter** component is active on the desired terrain.
2. **Load the Preset**

   * Click the **Load Layer Settings Data** button in the **TerrainPainter** Inspector.
   * Select the saved `LayerSettingsData` file from the file explorer.

   The preset will automatically be applied to the terrain layers.

{% hint style="success" %}
If you need to apply presets at **Runtime**, use the following [example script](/terraforge-documentation/how-it-works/runtime-scripting-api.md#applying-layersettingsdata)
{% endhint %}

***

**Terrain Assignment Window**:

* **`Terrains`** - an array of assigned terrains to which procedural painting will be applied.
* **`Add terrain from this object`** - Automatically assigns the current GameObject's **Terrain** component to the script.
* **`Assign child terrains`** - Adds all **Terrain** components found in the current GameObject's child objects to the script.
* **`Assign all terrains in scene`** - Adds all active terrains in the scene to the script's terrain list.
* **`Clear`** - Removes all terrains from the script's terrain list.

<figure><img src="/files/cCVZG2rZvhPdRW0nFlXB" alt=""><figcaption></figcaption></figure>

***

**Additional Settings**:

* **`Splatmap Resolution`** - The resolution of the splatmap for the terrains (`from 64 to 1024`).
* **`Color Map Resolution`** - The color/base map is a pre-rendered texture for the terrain color (`resolution from 16 to 2048`). This is shown on the terrain in the distance. High resolutions usually have little benefit.
* **`Recalculate bounds`** - If the terrain size has changed, the bounds must be recalculated. The white box must encapsulate all terrains.
* **`Refresh Modifiers`** - Reapplies and updates all modifiers currently assigned to the terrain layers.

<figure><img src="/files/t7sCay0PCCVIVkjUda4Q" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %} <mark style="color:yellow;">**Important Note:**</mark>

The **`Terrain Painter`** component **cannot be copied or moved to other scenes**. Doing so may lead to broken references, loss of data, or unexpected behavior.

To work across scenes:

1. **Save your settings** as a preset using the **`Save Layer Settings Data`** button.
2. In the target scene, **add a new `Terrain Painter` component** to your terrain.
3. **Load the preset** using the **`Load Layer Settings Data`** button to restore your configuration.

This ensures proper transfer of settings while maintaining stability and avoiding errors.
{% endhint %}


---

# 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://wiskered.gitbook.io/terraforge-documentation/how-it-works/terrain-painter.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.
