Sunday, December 27, 2009

Procedural Cities in XNA

It's been quite a while since I've talked about any development I've been doing. To be honest I have been quite busy with work and flight lessons, so I don't have much time to work on my hobby projects.

Lately I have been working on a procedural city generator in C#/XNA. I'm basing my work on the Metropolis project, which was in turn based upon a research paper presented at SIGGRAPH 2001.

I began with the procedural road map generator. It takes a heightmap and generates a road network from it.

Zooming in you can begin to see the subdivisions between streets where buildings will be built.

Zooming in even further makes the building lots even clearer.

Next, I began work on the 3D building creation. Here you can see many simple buildings all using the same texturing.

I then added more texture variety.

I finally added in the terrain with road texturing.

Zoomed out view showing the vast number of buildings generated.

And the final image showing "Central Park" (this city was generated from a heightmap of Manhattan).

I want to eventually release the source code for this, but first I need to clean up the code some more. I also need to tweak the renderer to run faster. Right now it is just brute forcing it, and doesn't utilize any form of level of detail or frustum culling.


John Leonard said...

WOW! Looks great!

XNA Connection said...

Hey, not bad at all. But it's a bit sad that you can only generate manhattan-like topologies. I suppose the algorithm doesn't support complex cities that we can find in Europe...

Claudia Vance said...

Nice work.

Would you be interested in trying out another procedural city generator? Our company released √úrban PAD about a year ago. The software contains four procedural content editors and a city generator. (Our approach to building generation is slightly different, though.)

Free trial versions are available on our site at and we'd be happy to give you an online demo.


dspnerd said...

The limitation of manhattan like landscapes is fixable. By switching to a 'sparse' approach and adding in other kinds of buildings either via generators or as actual models, you could increase the amount of diversity. Plus, it's not open source yet, so nobody's had a chance to upgrade it.