# Scatter

Thousands of rocks, bushes or trees on a terrain in one instanced draw.

A child mesh of a terrain node with `"instances": {"on_terrain": {...}}` scatters copies on the terrain's surface.

```json title="apps/docs/examples/scatter.json"
{
  "camera": { "position": [0, 6, 24], "target": [0, 1, 0], "fov": 45 },
  "lighting": { "rig": "golden_hour" },
  "environment": { "background": { "sky": {} } },
  "materials": {
    "dirt": { "preset": "gravel", "color": "#9c7656" },
    "stone": { "preset": "rock" },
    "brush": { "color": "#7a7a3a", "shading": "flat" }
  },
  "nodes": {
    "ground": {
      "mesh": {
        "geometry": {
          "terrain": { "size": [120, 120], "height": 3, "scale": 20 }
        },
        "material": "dirt"
      }
    },
    "rocks": {
      "parent": "ground",
      "mesh": {
        "geometry": { "icosahedron": { "radius": 0.5 } },
        "material": "stone",
        "instances": {
          "on_terrain": {
            "terrain": "ground",
            "count": 600,
            "scale": [0.3, 1.2],
            "squash": 0.4,
            "tilt": 15,
            "sink": 0.1,
            "clump": 0.5,
            "exclude": [{ "center": [0, 12], "radius": 5 }],
            "colors": ["#8a7060", "#6a5a50"]
          }
        }
      }
    },
    "bushes": {
      "parent": "ground",
      "mesh": {
        "geometry": { "cone": { "radius": 0.4, "height": 0.9, "segments": 6 } },
        "material": "brush",
        "instances": {
          "on_terrain": {
            "terrain": "ground",
            "count": 900,
            "scale": [0.6, 1.4],
            "max_slope": 30,
            "clump": 0.7
          }
        }
      }
    }
  }
}
```

![Render of scatter](/renders/scatter.jpg)

## Controls

- `count`, `scale` (a `[min, max]` range) and `seed`.
- `clump`: 0 is even, 1 grows in patches.
- `squash`, `tilt` and `sink` vary the shape and how it sits in the ground. `align` tilts copies to the slope.
- `max_slope`: degrees. Nothing grows on steeper ground.
- `exclude`: circles that stay empty, like a parking lot.
- `area`: limit scattering to part of the terrain.
- `colors`: per-copy tints.

## API Reference

### TerrainScatter

Seeded scatter on a terrain node (see [`Instances::OnTerrain`]).

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `align` | `boolean` | `false` | Lean copies along the ground's slope. |
| `area` | `[x, y]` | — | `[width, depth]` of the area to fill, centred on the terrain. Defaults to the whole terrain. |
| `clump` | `number` | `0` | Clumping 0..1: copies gather in noise-driven patches instead of spreading evenly. |
| `colors` | `Color[]` | — | Random per-copy tint, picked from this list. |
| `count` (required) | `integer` | — | Copies to place (fewer when masks reject spots). |
| `exclude` | `Exclusion[]` | — | Keep-out circles (the road, the lot, the building). |
| `max_slope` | `number` | `90` | Skip spots steeper than this many degrees. |
| `scale` | `[x, y]` | `[0.7,1.3]` | Uniform scale range `[min, max]`. |
| `seed` | `integer` | — | Overrides the scene seed. |
| `sink` | `number` | `0` | Push copies this far into the ground (half-buried rocks). |
| `squash` | `number` | `0` | Extra random vertical squash/stretch, 0..1 (flat pebbles, tall brush). |
| `terrain` (required) | `string` | — | Id of a node whose mesh geometry is a `terrain`. |
| `tilt` | `number` | `0` | Random tilt in degrees (rocks lean, brush sways). |
### Exclusion

A circle on the ground (`[x, z]` in the terrain's local space).

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `center` (required) | `[x, y]` | — | Centre `[x, z]` in the terrain's local space. |
| `radius` (required) | `number` | — | Radius of the circle that stays empty. |
