City procedural generation: Voronoï approach

By jjeromegerstch

As I was working to create my gamedev toolbox, I decided to tackle the city generation part. Here is a description of the solutions I’ve found to generate pieces of city.

One city piece

These pieces can later be linked. Focus points buildings can be added to create good landmarks.

full city without landmark

Here is the description of my Voronoï approach.

Splitting the tool to simple tasks

My first step as I create anything is to decompose my problem into sub tasks with two objectives in mind: easiness of implementation and re-usability.

For this tool I created 4 tools:

  1. City footprint generation
    This tool takes a polygon shape in input and create a city layout in output with buildings, roads and parks areas.
  2. Road generation
    This tool takes the Layout and modifies the geometry to integrate roads. It is also in charge of props scattering (street lights and other street props)
  3. Park Generation
    This tool takes the park area and is responsible to scatter vegetation
  4. Building generation
    This tool takes the buildings areas and creates a building for each cell of the layout.

Here, I will only focus on the city layout generation with Voronoï

City layout generation

The process

To obtain this result, I make the following operations :
1- Generate the blocks areas
2- Generate the road areas
3- Generate the sub-blocks areas
4- Segregate Buildings and greens areas
5- Merge areas

1- Block areas

To control the density of the blocks per square meter, I use a density map that’s made by painting a density attribute on an uprez version of the input shape.

Painting Density attribute

This density attribute is used to drive the scattering process, creating more dense point distribution where the attribute is higher.

Points scattered for Voronoi

When used by the Voronoi Fracture Node, I get more small blocks within the denses areas as shown bellow.

Blocks

The blocks areas are now ready to subdivide in step 3

2- Road areas

Road areas are created by substracting the blocks to the input shape

Roads footprint

3- Sub-blocks areas

To generate the block subdivisions, the block polygon is resampled to keep only the number of points necessary to have the required number of Voronoi cells and we add a point at the centroid of the block to achieve the desired look (having a green area at the center of the block)

Points for the Voronoi fracture
Sub-blocks created

4- Segregate Green and building area

This version of the tool makes all areas bellow a certain threshold be green areas. The rest becomes a building.

Green and buildings areas

5- Merge areas

Once all generated, the areas are merged and ready to be used as inputs to the different hda’s that creates the roads, parks and buildings

Merged final output

The interface

This tool gives access to the following inputs:
1- City plane input shape
2- Input a custom point set for the Voronoi fracture of the blocks
3- Painting Density
4- Selecting a map resolution
5- Setting Road Width
6- Setting number of buildings per block
7- Setting minimum size to create a block that can contains buildings
8- Setting minimum size for a single building on a Block

Input shape of the city layout and custom points for Voronoi fracture
Setting Resolution and Roads parameters
Setting Blocks parameters
Setting Buildings parameters

Live Presentation

Here is my live presentation of this tool in french for the Houdinimatic community.

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *