3D World Building
Expert guidance for level design with GridMaps, CSG bake, and occlusion — not lighting/atmosphere authorship.
NEVER Do
- NEVER forget to bake GridMap navigation — GridMaps don't auto-generate navigation meshes. Use EditorPlugin or manual NavigationRegion3D.
- NEVER use CSG for final game geometry — CSG is for prototyping. Convert to static meshes for performance (use "Bake CSG Mesh" in editor).
- NEVER scale GridMap cell size after placing tiles — Changing
cell_size doesn't update existing tiles, causing misalignment. Set it once at the start.
- NEVER ship a MeshLibrary item without verifying collision — Call
meshlibrary.getitemshapes(tileindex) (or inspect the source scene StaticBody3D + CollisionShape3D) before convert; empty shapes spawn visual-only geometry players fall through.
- NEVER bake CSG before the combiner has a settled frame — Extract meshes only after
await gettree().processframe (see [safecsgbaking.gd](scripts/safecsgbaking.gd)); baking mid-recompute yields empty or stale ArrayMesh data. Order: finish boolean edits → wait one frame → bake → delete CSG → add collision.
- NEVER animate CSG nodes during gameplay — Moving a CSG node within another forces the CPU to recalculate the boolean geometry, causing significant performance drops.
- NEVER place generic logic nodes in a GridMap — GridMap is highly optimized only for meshes, navigation, and collision. Use proxy tiles + scripts for spawns/triggers.
- NEVER use non-manifold meshes in CSG — Custom CSGMesh3D assets must be manifold (closed, no self-intersections). Non-manifold meshes break the CSG algorithm.
Available Scripts
MANDATORY: Read the appropriate script before implementing the corresponding pattern.
Do NOT Load lighting/sky/fog scripts or deep Environment tutorials here — route to godot-3d-lighting.
[collisiongen.gd](scripts/collisiongen.gd)
Automatic collision shape generation from meshes. Use when importing models without collision or for procedural geometry.
[gridmapruntimebuilder.gd](scripts/gridmapruntimebuilder.gd)
Sole streaming / runtime GridMap entry — batch tile placement, chunk-style rebuilds, and auto-navigation baking. Prefer this over ad-hoc WorldStreamer stubs.
[csgbaketool.gd](scripts/csgbaketool.gd)
EditorScript to bake CSG geometry to static meshes with proper materials and collision. Use when finalizing level prototypes.
[safecsgbaking.gd](scripts/safecsgbaking.gd)
Expert technique for safe CSG baking. Awaits the end of the frame before extracting baked meshes to avoid empty data.
[lodmanager.gd](scripts/lodmanager.gd)
Level-of-detail switching based on camera distance. Manages mesh swapping and visibility for large outdoor scenes.
[occlusionsetup.gd](scripts/occlusionsetup.gd)
OccluderInstance3D configuration for manual occlusion culling. Use for indoor levels with many rooms.
[gridmaplogicmanager.gd](scripts/gridmaplogicmanager.gd)
Proxy-tile pattern: replace invisible MeshLibrary markers with spawn/trigger scenes at _ready, then clear proxy cells.
[worldstreamer.gd](scripts/worldstreamer.gd)
ResourceLoader.loadthreadedrequest queue — stutter-free chunk instantiation after background load completes.
Golden Path (GridMap / CSG / Occlusion)
- MeshLibrary — Source scene: MeshInstance3D + StaticBody3D/CollisionShape3D → Convert To MeshLibrary → verify
getitemshapes().
- GridMap — Set
cellsize once, place cells, bake NavigationRegion3D. Runtime rebuilds: MANDATORY [gridmapruntimebuilder.gd](scripts/gridmapruntime_builder.gd).
- CSG greybox — Prototype with CSGCombiner3D → MANDATORY [safecsgbaking.gd](scripts/safecsgbaking.gd) / [csgbaketool.gd](scripts/csgbaketool.gd) → delete live CSG.
- Occlusion / LOD — Indoor rooms: [occlusionsetup.gd](scripts/occlusionsetup.gd). Distance swaps: [lodmanager.gd](scripts/lodmanager.gd).
- Sky / fog / WorldEnvironment — Out of scope; use peer godot-3d-lighting (keep only a DirectionalLight3D present if volumetric fog is enabled elsewhere).
GridMap Fundamentals
Setup (compact)
extends GridMap
func _ready() -> void:
mesh_library = load("res://tilesets/dungeon_library.tres")
cell_size = Vector3(2, 2, 2) # Set once; never after tiles exist
Cell API: setcellitem(pos, index[, orientation]), getcellitem, INVALIDCELLITEM, localtomap / maptolocal. For batch/runtime placement and nav bake, load [gridmapruntimebuilder.gd](scripts/gridmapruntimebuilder.gd) — do not paste a custom chunk streamer.
Collision verification
var shapes := mesh_library.get_item_shapes(tile_index)
if shapes.is_empty():
push_error("Tile %d has no collision — fix MeshLibrary source scene" % tile_index)
CSG Bake Order
- Finish boolean edits under
CSGCombiner3D.
await gettree().processframe (WHY: CSG dirty flags settle one frame late).
- Bake to MeshInstance3D + collision via scripts above; remove CSG from exported scenes.
- Never animate CSG at runtime.
Brush types (Box/Cylinder/Sphere/Polygon) are editor greybox tools only — not shipping geometry.
Streaming Decision
| Need |
Action |
| Runtime GridMap tiles / chunk rebuild + nav bake |
MANDATORY [gridmapruntimebuilder.gd](scripts/gridmapruntimebuilder.gd) |
| Large open-world scene streaming |
Peer godot-genre-open-world |
| Ad-hoc WorldStreamer inline stub |
Cut — do not reintroduce incomplete load-from-file TODOs |
Expert Techniques
Spatially Partitioning MultiMeshes
Partition dense props into regional MultiMeshInstance3D nodes so frustum/occlusion can cull whole clusters (single MultiMesh AABB draws everything).
GridMap Logic Proxies
Use invisible proxy tile IDs for spawns/triggers; at ready, getusedcellsby_item, instantiate logic scenes, clear proxy cells. Keep logic off the GridMap itself.
Interior-Mapping
For city-scale fake interiors, use a spatial shader on window planes — peer godot-shaders-basics. Do not paste full shader recipes here.
Edge Cases
- No collision: empty
getitemshapes → fix MeshLibrary source.
- CSG z-fight: tiny offset on subtraction brushes before bake.
Deep recipes (on demand)
| Topic |
Reference / script |
| GridMap / CSG bake walkthrough |
[gridmap-and-csg.md](references/gridmap-and-csg.md) |
| Chunk streaming / procgen rooms |
[streaming-and-procgen.md](references/streaming-and-procgen.md) |
| Proxy spawn tiles |
[gridmaplogicmanager.gd](scripts/gridmaplogicmanager.gd) |
| Threaded chunk load |
[worldstreamer.gd](scripts/worldstreamer.gd) |
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
- godot-project-foundations — scene tree, resources, and import basics before MeshLibrary conversion and WorldEnvironment setup.
- godot-physics-3d — StaticBody3D/CollisionShape3D patterns that must land in MeshLibrary source scenes or players fall through tiles.
- godot-gdscript-mastery — typed GridMap/CSG scripting, signals, and await/process_frame patterns used in bake and runtime builders.
Complements
Downstream / consumers
Master
- godot-master — library router and mirrored module entry for cross-skill discovery.