Procedural City Generation
The aim of this project is to procedurally generate a city onto generated or loaded terrain using ThreeJS library. The project could be made into a game or just used for visuals.
- Generate or load terrain
- Generate heatmap to decide different region centers
- Generate roadmap
- Detect if bridges need to be created
- Generate building plots
- Generate buildings
- Add details
Milestone 1 (29.02)
- At least flat terrain is generated
- Generate a basic heatmap
Heatmap that has city centers marked with blue.
Area around them could mark where buildings are higher.
Used Andreas' Midpoint Displacement for terrain generation and modified it a bit.
Milestone 2 (14.03)
- Improve terrain data representation
- Generate a roadmap
It's actually very random right now.
Milestone 3 (28.03)
- Generate curved main roads
- Implement at least grid style smaller roads/streets
Currently main road connects 3 randomly generated points and forms a curve.
Changing several parameters increases density of streets.
Milestone 4 (12.04)
- Fix roadmap bugs
- Modify roadmap generation with density heatmap
- Implement another road growth style
Blue color indicates higher density (near centers) but the color isn't perfect and I currently use it to get an approximation. Compared to last milestone, now primary roads are grown too. Primary roads currently use grid style growth in high density areas and organic growth elsewhere.
Milestone 5 (26.04)
- Improve cycle extraction from roadmap
- Implement water and bridges
First of all I decided to change 'building shapes and textures' goal to 'water and bridges' goal since implementing water could break something when done later.
Currently path finding algorithm is used to find path between centers only. The algorithm itself needs improving also. For other roads, road growing algorithm checks if target node of road is inside water and if that is the case, road growth angle is changed and target node is checked again.
Together with cycle extraction improvement, I implemented generating of invisible secondary roads at the end of road generation to create more plots for buildings. This allows generating of buildings without surrounding road. For each building, atleast one corner has to be near visible road.
Milestone 6 (09.05)
- Improve building shapes and textures
- Improve pathfinding algorithm
- Allow creating bridges for basic road growth
Cycles that are extracted from road graph represent regions that are surrounded with roads. These regions are divided into plots. In the following picture plot shapes can be seen.
Building shapes depend on the plot. Roofs are created separately and vary in shapes.
Road generation algorithm now starts growing from a single point which is one of the generated center point. Primary roads try to follow coastline and can also create bridges.
Latest version is accessible on http://morsakabi.com/baka/