Procedurally Generated Cities in Blender

Recently I found I had needed various large low-poly cityscapes for use in my renders. The problem here is that even the smallest cities require hours of tediously aligning buildings with streets. Great thing about tedious tasks, though, is that they can always be automated. In our case, a python script in Blender can get the job done!

Look familiar? This same city generator was used to create the banner featured on this site! Now you know it works, but how does it work?

Inputs

Ideally the script needs to work with something. While it is possible to leave all of the building generation up to the algorithm, I prefer to have some control over what it’s working with. With that in mind, I found it most useful to input building models, along with a few incredibly versatile window shaders I had created ahead of time.

Pictured above are some of the base building models and shaders that the algorithm uses. Vertex groups on each building contain the vertices that correspond to every direction (up, down, north, south, east, west). Offsetting these vertices makes it easy to procedurally modify their dimensions in any way necessary, without distorting any key features. The modification of dimensions is based on gradient noise, in which larger values create larger buildings. The foundation base at the bottom of the building is only visible if the building is placed on uneven terrain, which, along with the flow of roads, is determined by a premade street map.

The Output

This was the first scene created by the city generator. After creation, it took very little effort to finish the job. This consisted of adding lighting, water for the coastline, and baking the building shaders into atlased texture maps.

Example of a Handmade City

I created the below cityscape by hand before creating the city generator. Notable differences between the two include reduced city size, more organic street flow, and unique building designs.

One thought on “Procedurally Generated Cities in Blender

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: