godot-procedural
Skill54 starsChanged 14 days agoMITView on GitHub
Procedural generation in Godot 4.7 - seeded RandomNumberGenerator, FastNoiseLite terrain and biomes, TileMapLayer generation (cellular automata caves, BSP and random-walk dungeons, terrains), wave function collapse, Poisson-disc scattering, weighted loot tables, SurfaceTool/ArrayMesh heightmaps plus HeightMapShape3D, threaded chunk streaming. Use for random levels, terrain or runtime meshes.
In this repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- godot-2dSkill
- godot-3d-gameplaySkill
- godot-3d-renderingSkill
- godot-addonsSkill
- godot-animationSkill
- godot-architectureSkill
- godot-audioSkill
- godot-coreSkill
- godot-csharpSkill
- godot-editor-toolingSkill
- godot-export-ciSkill
- godot-game-feelSkill
- godot-gdscriptSkill
- godot-inputSkill
- godot-migrationSkill
- godot-mobile-webSkill
- godot-modding-dlcSkill
- godot-narrativeSkill
- godot-navigation-aiSkill
- godot-networkingSkill
- godot-performanceSkill
- godot-physicsSkill
- godot-shaders-vfxSkill
- godot-testing-debugSkill
- godot-uiSkill
- godot-xrSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Seed everything: Use one RandomNumberGenerator per generator with an explicit seed (rng.seed = hash("my seed") for text seeds).
- Very specific: line 17
Threads build data; the main thread touches nodes: Use WorkerThreadPool.add_task() for noise and mesh arrays, then call_deferred to add …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Procedural Generation (4.7)
Rules that save you later
- Seed everything. Use one
RandomNumberGeneratorper generator with an explicitseed(rng.seed = hash("my seed")for text seeds). Pass it down; never call globalrandf()inside generation. Show the seed in a debug overlay and save it with the game. - Data first, nodes last. Generate into arrays (
PackedInt32Array,Dictionary[Vector2i, int],PackedFloat32Array), validate, then write to TileMapLayer, GridMap or meshes in one pass. - Validate and retry. Flood-fill or path-check (
AStarGrid2D) that the start reaches the exit, enforce min/max room counts, then retry withseed + 1on failure. Cap the retries. - Threads build data; the main thread touches nodes. Use
WorkerThreadPool.add_task()for noise and mesh arrays, thencall_deferredto add nodes or set meshes. Seegodot-performance. - Rebake navigation after the level exists (
godot-navigation-ai).
Randomness API
RandomNumberGenerator:seed,state(save it to resume a sequence exactly),randi_range,randf_range,randfn(mean, deviation)(gaussian),rand_weighted(PackedFloat32Array)→ index (weighted tables).- Shuffle reproducibly: Fisher–Yates with your rng.
Array.shuffle()andpick_random()use the global generator. - Per-cell randomness without stored state: hash the coordinates, e.g.
hash(Vector3i(x, y, world_seed)), which is stable across runs and machines.
Noise (FastNoiseLite)
| Property | Meaning |
noise_type | TYPE_SIMPLEX_SMOOTH (default, terrain), TYPE_PERLIN, TYPE_CELLULAR (Voronoi: biomes, cracks), TYPE_VALUE |
seed, frequency | lower frequency = larger features (0.005–0.02 for world maps in tile units) |
fractal_type, fractal_octaves, fractal_lacunarity, fractal_gain | detail layers (FBM, 3–6 octaves) |
domain_warp_enabled + domain_warp_* | organic, swirly coastlines |
get_noise_2d(x, y)/get_noise_3dreturn roughly −1..1. Remap withremap()or(n + 1) * 0.5. Batch withget_image(w, h)when you need a whole texture.- Biomes: combine two noises (height + moisture, or temperature) and threshold them into a lookup table. Use a different
seedfor each noise. - Shaders and editor previews:
NoiseTexture2D(noise,seamless,as_normal_map,color_ramp). It generates on a thread, soawait texture.changedbefore reading its image.
2D tile generation
| Technique | Good for |
| Noise thresholds | overworlds, islands, biomes |
| Cellular automata (4–5 smoothing passes, wall if ≥5 of 8 neighbors are walls) | caves |
| Random walk / drunkard's walk | organic tunnels, guaranteed connectivity |
| BSP split + rooms + L-shaped corridors | classic roguelike dungeons |
| Room templates (prefab scenes/patterns stitched on a grid) | Spelunky-style designed variety |
| Wave function collapse | tile-adjacency puzzles, towns. Use the "Wave Function Collapse (WFC)" addon by AlexeyBond (TileMapLayer and GridMap) |
- Writing:
set_cell(coords, source_id, atlas_coords). For autotiling, collect cells per terrain and callset_cells_terrain_connect(cells, terrain_set, terrain)once per terrain. It's slow for big maps, so generate per chunk or use direct atlas coords. TileMapLayer.set_pattern()stamps prefab rooms saved asTileMapPatterns.- Big maps: chunk them (e.g. 32×32) and generate around the camera. Clear far chunks with
erase_cell.
3D generation
- Heightmap terrain: a grid of vertices from noise →
SurfaceTool(set_uv,add_vertex,index(),generate_normals(),generate_tangents()for normal maps) →commit(). Collision:HeightMapShape3D(map_width,map_depth,map_data), which is much cheaper than a trimesh. Scale the CollisionShape3D to match the grid spacing. - Fast path: fill
PackedVector3Array/PackedInt32Arrayyourself and callArrayMesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays). It's several times faster than SurfaceTool for large meshes. - Edit existing meshes with
MeshDataTool. Debug lines and gizmos:ImmediateMesh. - Scatter (trees, rocks, grass): Poisson-disc points →
MultiMeshInstance3D(one draw call). Setinstance_countaftertransform_formatandmesh. Raycast down or sample the heightmap for Y. - Modular dungeons in 3D: generate on a 2D grid, then place GridMap items or instantiate room scenes at
Vector3(x, 0, y) * cell_size(godot-3d-gameplay). - Large terrain with sculpting and LOD: the Terrain3D addon (
godot-addons).
Loot, names, encounters
- Weighted tables as a
Resource(entries: Array[LootEntry]withweight) so designers edit them in the inspector. Roll withrng.rand_weighted(weights). - Pity timers and "bags" (shuffle a list of outcomes and draw until it's empty) feel fairer than pure randomness.
- Markov chains or syllable tables for names. Keep the generated strings out of translation files.
Seeded noise maps, caves, BSP dungeon, Poisson disc, loot table, heightmap terrain and threaded chunks (compiled by the tests): references/patterns.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

