A deep dive into building a procedural medieval island map generator using Wave Function Collapse (WFC) on a hex grid with ~4,100 tiles. The post covers the WFC algorithm adapted for 6-edge hex tiles with 30 tile types, 5 elevation levels, and a modular multi-grid approach to handle large-scale generation. Key engineering challenges include a layered backtracking and recovery system for cross-grid constraint failures, cube coordinate math for hex geometry, and combining WFC with Perlin noise for organic tree/building placement. The renderer uses Three.js WebGPU with TSL shaders, BatchedMesh for single-draw-call rendering, GTAO ambient occlusion, depth-of-field post-processing, and a custom coastal wave shader with a CPU-side cove detection hack.
Table of contents
Carcassonne, but a Computer Does ItThe Multi-Grid ProblemHex Coordinates: Surprisingly WeirdTrees, Buildings, and Why Not Everything Should Be WFCWater: Harder Than It LooksMaking Tiles in BlenderMaking It PrettyOptimizationsSummaryThe NumbersTech StackTry ItCredits and ReferencesAbout MeSort: