Godot procedural generation

From thedivergentai/GD-Agentic-Skills · View interactive version

Godot procedural generation is an AI agent skill from the GitHub repository thedivergentai/GD-Agentic-Skills. Expert blueprint for procedural content generation (dungeons, terrain, loot, levels) using FastNoiseLite, random walks, BSP trees, Wave Function Collapse, and seeded randomization. Use when creating roguelikes, sandbox games, or dynamic content. Keywords procedural, generation, FastNoiseLite, Perlin

How to use this skill

Skill file

Procedural Generation

Seeded algorithms, noise functions, and constraint propagation define replayable content generation. Do not paste inline algorithm tutorials — load the MANDATORY scripts below.

NEVER Do in Procedural Generation


Golden Path (MANDATORY)

Every generator starts here — seed isolation, async data, main-thread commit:

  1. Seed & RNG — MANDATORY proc_gen_seed_history.gd: one RandomNumberGenerator per level/chunk; persist seed + state for shareable runs.
  2. Async chunks — MANDATORY multi_threaded_chunk_gen.gd: WorkerThreadPool.add_task → compute data off-thread → call_deferred("_finalize_chunk") for SceneTree/node work.
  3. Validate → bake nav — after tiles/meshes land on the main thread, rebake NavigationRegion (see godot-navigation-pathfinding).
var rng := RandomNumberGenerator.new()

func begin_generation(run_seed: int) -> void:
    rng.seed = run_seed
    WorkerThreadPool.add_task(_build_data.bind(run_seed))

func _build_data(seed: int) -> Dictionary:
    var local_rng := RandomNumberGenerator.new()
    local_rng.seed = seed
    var noise := FastNoiseLite.new()
    noise.seed = seed
    return {"heights": noise.get_image(64, 64)}

func _ready() -> void:
    # Worker returns here — safe for nodes
    pass

func _finalize_from_worker(data: Dictionary) -> void:
    # add_child / set_pattern / create_trimesh_collision — main thread only
    pass

Do NOT Load the full scripts/ folder. Open only the script that matches your algorithm row below.

Algorithm Decision Tree

| Layout / content need | Algorithm | Script (MANDATORY when chosen) |

|-----------------------|-----------|--------------------------------|

| Winding tunnels, rivers, simple paths | Drunkard's Walk | MANDATORY drunknard_walk_path.gd |

| Structured rooms + hallways | BSP | MANDATORY bsp_tree_rooms.gd |

| Organic caves / smooth terrain | Cellular Automata (4/5) | MANDATORY cellular_automata_dungeon.gd |

| Heightmaps, biomes, infinite terrain | FastNoiseLite → Image | MANDATORY fast_noise_noise2d_master.gd |

| Trees, rocks, spawns (no clumping) | Poisson Disk | MANDATORY poisson_disk_sampling_2d.gd |

| Tile adjacency / city blocks | Wave Function Collapse | MANDATORY wave_function_collapse_lite.gd (lite) or wfc_level_generator.gd (full rules) |

| Room graph before geometry | AStar graph layout | MANDATORY proc_gen_graph_layout.gd |

| 3D voxel / smooth terrain mesh | Marching Cubes base | MANDATORY proc_gen_marching_cubes_base.gd |

| Infinite chunked 3D terrain | ArrayMesh + LOD chunks | MANDATORY mesh_gen_infinite_terrain.gd |

| Plants / branching structures | L-System | MANDATORY l_system_tree_gen.gd |

| Contour / metaball maps (2D) | Marching Squares | MANDATORY marching_squares_metaballs.gd |

Routing hints: Simple path → drunkard; rectangular rooms → BSP; constraint tiles → WFC lite; open-world chunks → noise + multi_threaded_chunk_gen.gd. For roguelike run orchestration, hand off to godot-genre-roguelike.

Available Scripts

Core (always start here)

2D layout & placement

Noise & 3D

Expert Procedural Patterns

1. 3D Terrain via ArrayMesh (Marching Cubes)

For voxel-like or smooth organic terrain, use ArrayMesh to generate geometry from code.

2. Graph-Based Dungeon Logic

Don't generate your dungeon geometry first. Build a logical graph using AStar2D.

Deep dive (load on demand)

Drunkard walk, noise biomes, BSP, loot tables, WFC loops — references/algorithm-recipes.md.

Reference

Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing to a peer domain — do not preload the whole lattice.

Official Documentation

Related Skills

Prerequisites
Complements
Downstream / consumers
Master
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.