I mentioned before that I had two approaches to making the building textures: One would light windows completely scattershot. Each window had a fixed chance to be lit or unlit. The other approach was to light them in horizontal groups, so that the lit windows would always be grouped together.

Stepping back and looking at what I’m trying to simulate, I can see the scattershot doesn’t make much sense, and doesn’t seem to match what we see in cityscapes. Worse, all buildings had the same percentage of lit windows, which made the view even more monotonous.

All buildings should exhibit some level of lit-window grouping. The only difference from one building to the next is in how big each office / apartment is. Also, not all buildings have the same ratio of lit windows to dim ones.

So I replaced the old window-generating code with a new one. It randomly decides at the outset how big the interior spaces are, and what percent of the windows should be lit.

Now different buildings have different window shapes and different densities of lit windows and different group sizes. The city lights now look less like uniform noise and more like chaos that springs from complex ordered systems.

Tower Buildings

As I mentioned in the post on building shapes, my classic tower-style buildings weren’t going to cut it. I was supposedly making these buildings with elaborate stonework. My goal was to present the outline of such a building and allow the viewer’s imagination and prior experience to fill in the blanks with engravings and such. But I didn’t leave any blanks for them to fill in! Every building was all windows, edge-to-edge, top-to-bottom. I tore out the old code and replaced it with a new building generator:

These new buildings are very rarely covered in windows. They have vertical stripes or windowless areas running down the face of the building. The buildings are broken into tiers, and there are a few blank floors between each tier. It begins at the bottom, drops a tier into place, then puts a lid on that tier, then builds a new tier on top of the lid, onward until it reaches the planned building height.

I love the new one because it has a ton of parameters that govern the shape of the building:

How tall each tier is. (More accurately, how much of the remaining height is given to the current tier. One-half, one-third, one-forth, etc.)

How much (if any) the lid sticks out from the side, forming a ledge.

How tall the lid is, in stories.

If the corners of the building are explicitly windowless.

The grouping of the windows and blank areas on the face of the building.

If the tower gets narrower towards the top.

The window texture used.

The tint of the window texture, from a handful of various types of light sources.

These values allow for a huge number of meaningful changes to the shape of the structure, giving the world a ton of visual variety. Also, the vertical blank areas seem very subtle, but it’s shocking how the eye can instantly spot the break in the pattern:

Modern Buildings

These buildings looked fine to begin with, but they didn’t have a lot of variety. A slight change brought about compelling results.

Instead of just randomly cutting off sections of a cylinder, it chooses to do so at regular intervals. And it can make cuts in 45 degree sections as well as 90. And as with the other buildings, I added some vertical window gaps. Although, it doesn’t really make the buildings that much more interesting.

They look interesting in wireframe, but without the lines one deformed cylinder looks much like another.

Other Changes

As you’ve probably noticed in the screenshots, I’ve added a few polygons of roof clutter to hint at HVAC systems and whatnot. The building colors are now limited to a handful of hues that match common lights. And I put larger gaps between buildings, which gives their silhouettes more opportunities to stand out.

A few improvements to the existing systems made a big difference to the overall appearance.

I was actually wondering if a really simple statistical approach would work well for generating “interestingly-grouped windows”, two tweakable parameters. Going from left to right along a floor, start by having the first window lit or unlit with p(lit)=0.5 (tweakable), then have each following window be the same as the previous window with p(same) >= 0.5, that should, on the whole, generate runs of windows with the same light state, but still vary per floor.

Your project is insanely interesting, probably because even though I’m a programmer by vocation I mostly do server side stuff and have never done any 3D programming. Second, because my wife is an architect and it kinda rubs off on you. Even though I’m more interested in city planning which my wife cannot stand… go figure.

THese new forms are an excellent move toward higher realism! I really like how you tackled the “traditional” buildings!

You could totally design an algorithm that would create an ideal building/living space that would put many modern architects to shame :) (I am very sad at the direction modernism and post modernism have taken us. They attempt to be utilitarian, but turn out to be ugly AND un-usable)

So show us a city already! The newer buildings look nice and you say they make a big difference to the overall appearance, but we haven’t seen the new overall appearance yet. I can’t wait to see another big city as a benchmark for how far you have come right now.
Or are you waiting for the final version before showing off your new toy?

Just to prove how universally appealing this series is, the grammar police have arrived. Second paragraph under “tower buildings” (located below the picture) contains the following: “It beings at the bottom, drops a tier into place…”

And yet, I’m compelled to admit that while neither programming nor city planning/architecture are particular interests of mine this series has endlessly fascinated me and I’ve eagerly followed each post, even going so far as to look up concepts I don’t understand. I really like the improvements you’ve made. They have a more realistic look to them, especially in the tower buildings. I was able to suspend disbelief before to accept them as real but now there’s very little suspension even involved.

I had a thought about what could be added to the individual window images: blinds. Not curtains drawn from the side (though those would work as well), but blinds drawn down from the top. Seems like they’d be really easy, just darken from the top a random amount, with a distribution where all-the-way-open and all-the-way-closed are the most common.

If you plan to illustrate the cityscape from a bird’s eye POV, the tops of a lot of buildings usually have some form of lighting to outline the roof features. Also, many buildings have various arrays of antennae or lightning rods. Some even have radio towers.

@Alan Try http://nehe.gamedev.net/ There are tuts on the left. Highly recommended. He explains things very clearly – it’s what I used to get me started in opengl.

Shamus, I’m really loving this series. Have you given thought to the city planning issue (grid-based)? Like you said time constraints make it difficult but maybe you could do a cheap form of zoning, like in Sim City 1: you declare an area residential and only have very short buildings generated there, tall buildings in cbd, short but long/wide buildings in industrial zones. You could leave large areas to simulate parks, etc. This might be faster and still fairly real looking at a glance instead of doing angular or circular city planning. Terrain height sounds fun at first but may get kinda tricky to do nicely (working out base placements of buildings so sections don’t end up floating and so on) – most cities are fairly flat anyway, or at least areas of construction are – so it could still be fairly realistic to have large flat areas of buildings and sloped (empty) areas leading to the next plateaux.

@Alan: If you want to learn to program, just choose a language and find stuff on the net to show you how to run it.

It doesn’t matter too much what your first language is, because other languages will have simmilar concepts. I would reccomend either C (very low level language) or python (very high level language). Learning another language is much easier once you know the basics.

Having chose a language, google: “learning foo” where “foo” is the language chosen.

The most important thing about learning to program is to write programs, get them working, and understand them. Python is good in this regard because all you have to do is install it and you can type code in the interpreter and see what it does immediately. On the other hand if you are using a good IDE in C++, C#, (such as Microsoft Visual C++ or XCode) then there is a debugging mode where you can step through the code line by line and see what is happening.

I assume that you are interested in making games.

As far as a language that is easy to do games or 3d graphics in, choices are C++ (OpenGL), C#(XNA, see RB Whitaker’s wiki), and python (pygame and pyopengl).
There are most likely other good choices that I am not qualified to talk about.

I guess I’m being greedy, but I’ll have to second Kasper’s comment. I’d like to see a whole cityscape with the new improvements, but I guess I can wait. How many parts are left before the series is complete?

It looks really good, Shamus. One thing you should add to the roof clutter, though, is the occasional large spike with bright red and white lights, particularly on taller buildings.

You might want to think about the fact that many skyscrapers nowadays make use of exterior lights, so the occasional neon stripe or bright light shining down from a building corner or up from the street can make a big difference. You would have to add texture (not at the distance this is likely to be viewed from), just a random-shaped parabola of “lit” area that is gray, yellow, or orange.

One suggestion: If you want the modern rounded skyscrapers to look more interesting, you need to cut away sloped sections horizontally on some buildings. For example, the building may be a cylinder at the base and then have a chunk taken out, coming to a sharper angle at the top. Windows can continue along the sloped wall.

It also might be a boxy section and then another, rounded section on top (though the reverse is rare and ugly).

dding semi-randomized shapes like a dome or a pyramid to the top of either traditional or moden skyscrapers would also drastically improve things, but of course, we’re getting into “should I or shouldn’t I spend the time I have on this aspect” territory. Regardless, this is an absolutely amazing series and I heartily congratulate you for doing it.

I have enjoyed this series immenselly as well, being interested in programming, procedural generation, city planning, and architecture (in that order). I had a handful of possible tweaks that I don’t think have been mentioned.

1. A very small percentage of buildings could have helicopter pads.

2. If LA is any indication, sides facing freeways sometimes have 5-6 floors of windows missing for a billboard.

3. Buildings owned largely by one business often have the name of the business extruded out on the side, well lit even in the night. Procedurally generating business names probably isn’t a good use of your time though. And doing things like a single letter logo may not look right.

I’m not sure how important this would be in a project like this, but just as a side note in a lot of cities there are code requirements that state tall buildings must set-back a certain amount so that sunlight can still reach street level through the day.

That’s why many of the classic old buildings are shaped the way they are.

You seem to have lost the old “Sears Tower” style that you describe in your third post in your rewrite of the code. I think that adding that back in would add some interesting variety. Just remember, the bottom is always the widest part, so it would be easier to code by taking a rectangle and subtracting areas from it instead.

Also, I think the ground story “caps” should have their own style of windows. Brighter, always on, maybe two stories tall, with more colour variety. This could represent the shops and elaborate lobbies that tall building often have. You wouldn’t see much of it because of the canyon effect of the towers, but it would make for interesting little splashes where you could.

And finally, little flashing red or white lights at the corners of the buildings and on the roof clutter would be an easy addition that would add a lot to both believability and to visual interest. Splashes of brightly coloured light projected on to the sides of your showcase skyscrapers might also be fun, since several iconic towers are so lit.

I love this. I absolutely love it. I’m going to college next year to study Software Engineering (rather, it’s equivalent here in Buenos Aires, called IngenierÃ­a en InformÃ¡tica), so this is very, very fascinating for me. The college I’m going to (Austral) was very good at showing what types of projects students could do during the 5 years it would take to finish the course, but not a single one of them had such a thorough explanation of the whole development process. I mean, looking at a finished project was pretty interesting, but this whole “how I started, what worked, what didn’t, and how I fixed it” approach beats it.

That said, here are some suggestions: most buildings have lights on the outer rim of their roofs, mostly to signal helicopters that they really shouldn’t fly into the building. Speaking of helicopters, perhaps you could add a square made of flashing red and white lights in the middle of some flat-topped buildings to hint at a Helipad. Also, as many have said before, antennae towers, wider streets to suggest highways and avenues, and maybe a random chance that Godzilla will appear in the city.
Disregard that last suggestion.

Just want to add another voice to the ‘rooftop lights’ suggestion.
I think features like masonry trims and billboards are too restricted and specific for the simple procedural approach you’re taking. But summit lighting is a visible characteristic of most city-at-night photos I’ve seen, and would probably be quite a cost effective addition in relation to the work and rendering required to add them.

It’s interesting that this project “needs” to use the same techniques to “paper over the gaps” that trad. SFX model photography does. See: The Bladerunner documentary footage for how they made the cityscape at the start, and why the street set looked like it did.

I remain totally gobsmacked over how much innate clever this sort of thing needs to pull it off. Like so many things in real life, it always sounds easy to do. Shamus, you are obviously worth your paycheck.

I did notice that the perspective seems off in one of the building row tests, but hey, it’s a test and I have no idea how to fix whatever Mr Eyeball is telling me is out of skew. It’s still extremely clever. I’m particularly impressed by how you keep coming up with simple sounding fixes to what presents as a complex problem. And all without any mind-altering drugs too.

Like what Patrick said. With the modern buildings you could try adding steps. Start creating a cylinder that is a random percentage of the height of the building. When it cuts off a chunk make it step up to the next level if needed.

I don’t know how hard that would be or if it would be worth it but it is an idea. Probably adding lights to the roof would define the shape more and make them more individual so it might not be necessary. You may need to add some greebles.
(http://en.wikipedia.org/wiki/Greeble)

I agree that signage would not go astray. Probably should be a small image, one word or both. Maybe not worth it for the purpose of this activity. They could be added in later to fit whatever the story called for.

This could be mimicked by drawing a bright neon line down the tower from the top (but not necessarily all the way to the ground) on either side of a “cut”. It could help differentiate the modern towers.

Great article and it is worth mentioning that Mini blinds are notorious for collecting dust. Their horizontal position creates a flat surface for dust to land on. In addition, they’re almost always next to an open window, bringing in extra dust by means of the breezes.