A fully explorable 3D dungeon generator built from scratch in Unity — combining cellular automata cave generation, the marching cubes algorithm, and dynamic flashlight lighting to produce natural-feeling cave environments that are unique every run.
This project is a fully explorable 3D dungeon generator built as a solo course project in Unity. The goal was to create a system that generates natural, believable cave environments entirely through code — no hand-crafted level design. Every run produces a completely unique dungeon with different layouts, passages, and treasure chest placements that players can explore in first person.
The technical centrepiece is the combination of cellular automata for cave shape generation and the marching cubes algorithm for seamless 3D geometry — two techniques that together produce organic, non-blocky environments. The dark atmosphere with dynamic flashlight lighting gives the space genuine tension and rewards thorough exploration.
Cellular Automata Cave Generation Implemented cellular automata to generate natural, irregular cavern formations from scratch. Each generation step applies neighbourhood rules to a 3D grid of cells, organically growing cave shapes with smooth passages, dead ends, and open chambers — no two dungeons are ever the same.
Marching Cubes Algorithm Applied the marching cubes algorithm to convert the cellular automata voxel grid into a continuous 3D mesh with no hard blocky edges. This produces seamless wall connectivity and organic surface geometry — a significant step up from simple voxel-based approaches.
Procedural Cave Textures Developed custom procedural textures applied at runtime to cave walls and floors, giving the environment a cohesive earthy aesthetic without any hand-authored texture atlases.
Dynamic Lighting & Player Flashlight Built immersion by setting ambient environmental light to near-zero, forcing players to rely entirely on a player-controlled flashlight for exploration. The result — as seen in the screenshots — creates genuine tension when navigating dark corridors and a rewarding sense of discovery when the flashlight reveals a new chamber or treasure.
Procedural Treasure Chest Placement Designed a placement system that randomly positions treasure chests in valid cave locations — preferring dead ends and tucked-away spots to reward exploration. The flashlight-chest discovery moment seen in the hero screenshot was a key design goal.