Generate DLA Cells
Generates organic growth patterns using Diffusion-Limited Aggregation (DLA).
Starting from one or more seed cells, random walkers roam the grid and stick when they touch the existing aggregate, forming branching, vein-like structures. With different biases and connectivity, DLA can create roots, rivers, coral, frost patterns, or cave-like blobs.
What it does
- Initializes an occupied set from a chosen Seeding mode (manual points, Tilemap tiles, or a filled RectInt).
- Spawns Walker Count random walkers inside Bounds.
- Each walker takes up to Max Steps Per Walker random steps:
- Moves in cardinal directions (or 8-way if enabled).
- Optionally biases movement toward center or toward a target cell.
- When a walker reaches a cell adjacent to the occupied set, it sticks and that cell joins the aggregate.
- Returns all occupied cells as Vector2Int positions.
Inputs
| Field | Description |
|---|---|
| Bounds | BoundsInt region where walkers move and growth occurs. |
| Seeding - Seed Source | Where initial occupied cells come from: Manual Points, Tilemap Tiles, or Rect Region. |
| Seed Points (Manual Points) | List of Vector2Int cells (must be inside Bounds) to initialize the aggregate. |
| Seed Tilemap (Tilemap Tiles) | Tilemap to scan for initial seeds (only cells inside Bounds are considered). |
| Seed Tile Filter (Tilemap Tiles) | Optional TileBase filter - only tiles equal to this are used as seeds. Leave None to use any non-null tile. |
| Seed Rect (Rect Region) | RectInt region whose cells become the initial seed (filled completely). |
| Walker Count | Number of random walkers to simulate. More walkers ⇒ more/faster growth. |
| Max Steps Per Walker | Per-walker step budget; if a walker fails to stick by then, it stops. |
| Use 8 Neighbors | If enabled, walkers move in 8 directions and “touch” includes diagonals (more branchy, fine detail). If disabled, movement/adhesion are 4-way (chunkier). |
| Bias To Center | 0–1. Pull toward the center of Bounds. Higher values gravitate growth inward. |
| Bias To Target | 0–1. Pull toward Target Cell. Higher values steer branches toward a goal. |
| Target Cell | Vector2Int goal used when Bias To Target > 0. Hidden otherwise. |
Outputs
| Field | Description |
|---|---|
| Cells | All occupied (grown) Vector2Int cells produced by the DLA run. |
| Used Bounds | The BoundsInt used by the generator (mirrors input Bounds). |
How it works (intuition)
- DLA grows by accretion: walkers wander until they touch existing growth, then stick. Repeating this creates natural, branching patterns.
- Use 8 Neighbors makes sticking and motion consider diagonals → more delicate, dendritic structures.
4-way encourages chunkier, orthogonal aggregates. - Bias To Center and Bias To Target influence the random step choice each tick. Even small biases can visibly steer the pattern:
- Center bias → inward-pulling clusters.
- Target bias → branches reaching toward a waypoint (e.g., spawn to exit).
- Seeding determines the initial nucleus: a single point, a line/area from a tilemap, or a whole rectangle for “growth from a wall/shoreline.”
Tips & pitfalls
- Seeds matter: A single point seed yields classic branching “coral.” A line or rectangle seed creates growth fronts (like frost creeping across glass).
- Walker budgets: If growth seems sparse, raise Walker Count and/or Max Steps Per Walker so walkers have more chances to stick.
- Connectivity choice: Use 8-way for natural, lacy branches. Use 4-way for bolder, grid-like formations that play well with Manhattan pathing.
- Steering: Subtle Bias To Target (e.g., 0.15–0.35) can guide a main branch without collapsing variety.
- Post-process: Pair with filters to shape gameplay:
- FilterCellsKeepLargestRegions – keep one main mass.
- FilterCellsRemoveSmallRegions – remove specks.
- FilterCellsJoinAllRegions – connect pockets with corridors.
- FilterCellsBridgeDiagonals – ensure 4-way connectivity.
- Painting: This action outputs geometry only; follow with your tile paint/fill steps to visualize as rock, water, vines, etc.
Determinism: Uses UnityEngine.Random. For reproducible runs, set a seed first with Random → Random Init State.