World Generator Documentation
The World Generator is a node-based procedural generation tool designed to create rich, varied environments. It translates high-level noise and logic into physical Unity Tilemaps and Prefab placements.
Key Concepts
1. GenGraph
The "brain" of the generator. A GenGraph is a node graph asset where you define your generation logic.
- Nodes: The individual operations (e.g., Perlin Noise, Threshold, Math).
- Ports: Connection points that pass data between nodes.
- Channels: The data flowing through ports (
Float,
Int,
Bool Mask,
Point List,
Placements).
2. Biomes
A BiomeAsset defines how Logical IDs are translated into actual Unity tiles.
- Maps a name (e.g., "Wall") and an ID (e.g., 2) to a set of tiles.
- Allows the same generation logic (the graph) to look completely different (e.g., a "Cave" biome vs a "Forest" biome).
3. Execution Pipeline
The generator runs in a specific sequence:
- Compilation: The graph is converted into an efficient execution plan.
- Execution: Nodes run in order, often using multi-threaded Unity Jobs for performance.
- Snapshot: The result is captured in a
WorldSnapshot. - Output: The snapshot is written to scene Tilemaps and Prefabs are instantiated.
Workflow
Step 1: Create a Biome
- Create a
BiomeAssetin your project. - Define your mappings for common Logical IDs like
Floor(1) andWall(2). - Assign tiles or RuleTiles to each entry.
Step 2: Author the Graph
- Create a
GenGraphasset. - Open the Dynamic Dungeon Editor window.
- Add nodes to create your terrain (e.g.,
Fractal Noise→Threshold→Cellular Automata). - Connect your final result to a
Tilemap Outputnode.
Step 3: Set Up the Generator
- Add the
TilemapWorldGeneratorcomponent to a GameObject. - Assign your
GraphandBiome. - Configure Layer Definitions (mapping graph outputs to specific Tilemap layers).
- Click Generate or Bake.
Component Reference: TilemapWorldGenerator
| Setting | Description |
|---|---|
| Graph | The GenGraph asset to execute. |
| Biome | The BiomeAsset used for tile mapping. |
| World Dimensions | The size of the generation area (Width x Height). |
| Layer Definitions | List of Tilemap layers. Each layer links to a port name in the graph. |
| Seed Mode | Switch between Stable (fixed) and Random (changing). |
The Bridge: Dungeon Generator Node
The Dungeon Generator Node is a special node that allows you to integrate the Constraint Generator directly into your World Generator graph.
How it Works
- Input: It takes a
Point List(the locations where dungeons should start). - Processing: It runs the Constraint Solver internally using a selected
Dungeon FloworOrganic Settings. - Outputs:
- Logical IDs: Emits a channel where the dungeon floor/walls are marked.
- Prefab Placements: Emits a list of room prefabs to be spawned.
- Reserved Mask: Emits a bool mask of the entire dungeon footprint.
Typical Bridge Setup
Point Grid → Poisson Sampler → Dungeon Generator Node → Tilemap Output
You can use the Reserved Mask to "carve out" the dungeon from other terrain. For example, use a Blend Node to ensure that mountains or rivers don't generate where the dungeon has been placed.