Drawing Board IX: Procedural Building Generation
So, first things first: apologies for the paucity of updates recently, some work-related upheaval has been eating up a good deal of my spare time. But with everything now squared away (for the moment) regular updates should be resuming!
The topic today is one that's come up a number of times in the forums, as well as being something I've planned to write about since the project started: procedural generation for buildings. This is something that I believe will be a key feature for Metropolis, one of the things that will truly make it a "next-generaton" (no pun intended) game. But let me begin, as always, with the Disclaimer:
IMPORTANT DISCLAIMER
This series of posts are not to be read as "official" ideas for the Metropolis Project, they are simply my personal thoughts about what some cool game features might be. The final feature set for the game will be decided by the community and the development team contracted to build the game, and may not include any of these things.
Anyone who's played city building games extensively is familiar with a problem that compounds as your city expands; a growing sense of artificiality brought on by the limited number of building models. In the first Sim City it wasn't such a problem: the game was all about strategic simulation and didn't make much pretense of looking attractive. But as games evolved and graphics improved, developers began looking for new ways to increase the visual impact of simulated cities, and players have become increasingly focused on making realistic and good-looking, as opposed to just functional, cities. The "Repetition Problem", as I would term it, is a barrier to that goal: building models which look attractive enough on their own look false and uncanny when they are repeated in close proximity. The problem is often especially acute among service buildings (e.g. fire stations, schools, etc.), which even in modern games frequently have only a single model for a given function.

Someone needs to hire a new architect.
Traditionally, developers have attacked this barrier along a number of vectors. The most obvious is the brute-force method of simply creating more and better-looking building assets. This allows bigger cities with less variation, and spaces out repetitions to make them less noticable. There are a couple downsides to this approach: first of all, 3D assets represent one of the most labor-intensive (and thus expensive) aspects of development. A game designer risks spending a lot of their budget on a feature that becomes less important the more it's developed. In other words, having twenty variations on a suburban house as opposed to ten isn't going to affect sales very significantly, but it will cost twice as much to develop.
However, even if that negative is overcome by harnessing the power of player-created assets, another, more fundamental barrier starts to emerge. As more and more assets pile up, the program itself grows increasingly bloated and unwieldy, eventually reaching a point where it taxes system resources so heavily that the game becomes unplayable. Any Sim City 4 player who has a plugin folder with thousands of buildings can attest to the effect on game speed and storage; and yet even such a massive collection is dwarfed by the variation present in reality: it's estimated that the New York metro area has close to a million unique structures.
Since it's clear that trying to create a realistic number of unique buildings by hand is hopeless, developers have used other tricks to beat the Repetition Problem. Most of these involve introducing randomness to some aspect of the building besides the model. In Sim City 4 this was accomplished by using lot models which could be distinct from the actual building; the structure was the same, but the surrounding elements like trees and sidewalks were varied. This worked reasonably well for smaller buildings, but fell apart as the models scaled up: two identical skyscrapers are going to look the same whether one has a bus stop outside or not.
Fortunately, the Repetition Problem has a solution: procedural generation. If you're not familiar with the concept, procedural generation simply means that instead of using 3D assets, buildings are created by the program on the fly, following a set of rules laid out in a script (you can read a more detailed explanation here.) Textures are often reused between different buildings. The result is that a large number of buildings can be created without modelling each structure individually; and if the proper "rules" are established in the generation script, the buildings will look varied enough to seem random, but plausibly shaped enough not to seem odd.
This technique works, paradoxically, because of the large degree of similarity between most urban buildings. "But wait!" you're probably thinking, "You just said that buildings looking the same was bad!" The important thing here is to draw the line between "similar" and "identical". Human brains are very good at pattern recognition: two things which are exactly identical stick out like a sore thumb, even where two nearly identical things don't. Take a forest for example: the trees are all largely similar, but the forest looks natural. However, two or more tree that were exactly the same would stand out and look artificial. The same applies to cities: let's face it, most buildings in urban areas are fairly boring and look like other buildings; But they do have minor variations which make them unique. Two buildings side by side with exactly the same shape stand out. With a procedural approach, you could make a large number of similar but not identical buildings.

How would procedural generation work in a game context? Procedural scripts would be handled in exactly the same way as traditional building assets: they would be assigned properties that determined the context in which they could appear and their values for the simulation (wealth level, occupancy, etc.) The only difference is that, when the simulation selected them to be constructed, they would not be simply "plopped" like a 3D model, but fed to the procedural generation program, which would determine their shape in that instance and give the result back to the main simulation. To be sure, this requires more processor cycles than just placing a model, but since the procedural calculations would only be required sporadically, as new buildings are constructed, the overall burden on the CPU would probably be minimal.
For modders, this would be a great opportunity for creating building styles rather than individual buildings; with a few textures and a good script, a modder could create an entire neighborhood of authentic-looking buildings in the time previously required for just one. The scripts that are created by the community could then be shared and downloaded just as buildings are now. The player could include them as plugins which would be used in whatever context they specified.
As an example of how this would work, let's look at a hypothetical situation. Say I wanted to create an old North German town; I could create a script which would specify houses that have peaked roofs, white plaster walls and dark crossbeams (the "Fachwerk" style, to be more specific). As the town grew, the script would create buildings which were otherwise distinct but shared these features, giving an impression of unified style but not looking like the same building repeated ad nauseam. Achieving the same effect by individually creating enough similar-but-unique buildings to create the appearance of randomness would take much longer and consume more system resources.
This is not to say that unique models on the traditional pattern would not be necessary; quite the contrary. But ultimately I think the trend would be towards using unique models for buildings that should also be unique in the context of the game, that is, buildings which appear in the city only once. Scripts would provide the "filler" which constitutes most urban landscapes.
On a final note: while procedural city-building might sound fanciful to someone used to the old paradigm, there are no significant technological barries to implementing this kind of system; If you don't want to take my word for it (and you shouldn't), take a look at two pieces of software that are using procedural generation to create 3D cities already: CityScape by PixelActive (Update: no longer available)and CityEngine from Procedural. Granted, these aren't games themselves. But they nonetheless provide a stunning demonstration of what's possible with this technology.
5 reponses to "Drawing Board IX: Procedural Building Generation"
1. John...This comment may not
John...This comment may not be specific to the topic discussed but (as many of your articles do) it got me thinking about another aspect of 'game design'. It seems that the intent to create unique yet realistic cities will always be a 'hot topic' for game players as next-generation games move forward. The possibility to 'personalize' ones own city are probably as endless as the number of players that enjoy this style of game play but (as you have pointed out) it does come with some complications. When I read the discussions about 'modding' existing games, the interests are as varied as the number of contributors....from building styles to vehicle types; traffic management to city budgets; international trade to topographical features...the preferences could go on and on. I would be interested in reading any thoughts you may have about designing into the game the environmental consequences and 'realistic' solutions that address the issues that our beautifully created cities produce. Aside from the typical answers of mass-transit, bike lanes or more parks, what are your ideas about including things like energy-efficient buildings; wind, solar and nuclear power and waste recycling ? Do you think that might be an area worth exploring as a truly next-generation game of the future ?
2. Absolutely, I think that's a
Absolutely, I think that's a simulation element that most people would like to see included. As far as buildings go, I think it would be relatively easy to include power consumption, waste production, and any other environmental variables as part of the building properties. I think a lot of that would end up tying in with the rest of the simulation too, especially the economic aspect; For example, the operating cost of coal power plants would obviously be tied to the price of coal; But you could also do something like tie the relative NIMBY effect to the education level, so that your population would be less accepting of dirty power and more comfortable with something like nuclear as the education level rose. Lots of possibilities!
3. That sounds magnificent! Say
That sounds magnificent! Say I want a city in the style of New York Art Deco. I just tell the game to use that style (which is different from Miami Art Deco), and put in the building codes (maximum height at certain distances from the road, etc) and let my city organically grow by letting buildings randomly grow that fit the specifications. Maybe I could alter some parameters and add some new textures and make something reminiscent of Metropolis (only with the Workers city being nearby instead of underground).
I would also like to know if the number of dots in the password section is the same as the number of characters used in a password because I forgot my password and rely on using my browser at home (which stored my password).
"Words are words; explanations are explanations, promises are promises, but only performance is reality."
Always do your best and you will always be better than the best in my eyes.
4. Exactly... although creating
Exactly... although creating the actual script would be less intuitive than making an individual building, you could then generate a limitless number of buildings in that style (textures would still have to be created by hand, but could be reused over many different buildings).
Not sure about the password thing... but you should be able to reset your password if you've forgotten it.
5. This is, in fact, the way to
This is, in fact, the way to think about The Metropolis Project. There is literally no reason to land anything short of a full procedural engine for generating assets for the game. I propose an addition to this.
The main engine component to set rules for how buildings are supposed to look and then introducing deviations within that rule set is certainly necessary. It will get you exactly what you describe. What should also be permitted is a stand alone building editor to either plop down a building into a designated space with full in-lot components and structures, or the ability to take a procedural building already generated in-lot and edit it's layout, components and structures.
For my example, I have a down-town sort of area where some corporate structures have built up. I want a particular building to have a particular look. Using what the engine has already come up with, I modify the number of floors, knock out the first two and put the thing up on those thick concrete-reebar stilts. Between these stilts, I put in an access point for the elevator, some parks and junk, a few benches, some trees, maybe a fountain and then a hedge along one street. I exit the editor and sit back to watch people mill about in the new "park area," sitting on benches and looking at the fountain.
The joy to be found in molding sections of your city to suit your needs or aesthetic desires is a nice distraction from the demanding task of keeping everybody happy within a city that is growing and changing. Keeping the game fresh will be a real task since trying to grow the city to the edges of the map is just part of the phases a city goes through during play. Being able to park your butt on a view of a building and remind yourself, "Hey, I made that!" will extend the playability aspect of your project as well as increase the draw that players feel toward their creations.
Post new comment