Stolen Pixels #83: Left 4 Dumb: Part 5

By Shamus Posted Tuesday Apr 21, 2009

Filed under: Column 11 comments

So I made another comic that has Left 4 Dead stuff in it and I was kind of hoping you would read it.

Also, The Escapist has been nominated for a Webby award. As you well know, online media companies make their money almost exclusively from winning online awards. (In fact, this is the real reason print media is struggling so badly. The Star Tribune wouldn’t be in so much trouble if they were eligible for some web awards.) I think it would be great if The Escapist won. </hint hint>.

 


 

Procedural City, Part 6: Sky

By Shamus Posted Tuesday Apr 21, 2009

Filed under: Programming, Projects 51 comments

Gradient Sky

I need to make a sky for my city. So… I guess I better add one.

pixelcity_sky2.jpg

This is not religious iconography.
This is not religious iconography.
There are a lot of techniques for rendering skies. The most common is probably the “skybox”, which is a simple box with pre-rendered images pasted on it. Sometimes the images are taken with a special camera, but more commonly they’re designed by artists. To the right is an example of a skybox, which I gleefully pilfered from Google. (You could cut that image out and fold it up along the white lines to form a real-world skybox if you wanted.) Imagine folding up the box and wearing it on your head with the images facing inward. Note that all around you would be a seamless mountain vista. Also note that you would look like an idiot and likely bump into things.

On the computer, it’s possible to draw this box, and then render everything else in the world on top of it, which creates the illusion that the mountains are a huge distance (infinite, actually) away. Now, my skybox isn’t going to be box shaped. Since I’m focusing on making a night time scene, I don’t need the top or bottom. So I’ll make some textures and place them on in side of a shortened tube instead of a cube. So, the viewer of my program is unwittingly wearing a lampshade on their head. Ha ha.

I make a smear of colors and put it on the lampshade.

pixelcity_sky3.jpg

It’s amazing how you can blur just about any two colors across the view and see it as a horizon. I start with a random warm color, which then fades to a blue, then fades to a very dark blue, and then to black. The specific colors are randomly chosen. I don’t know if it’s supposed to be a sunset or simply city lights bouncing off the atmosphere. It’s a little bright and colorful to be ambient light. But it goes all the way around the horizon, which is something sunsets don’t usually do.

I add some stars.

pixelcity_sky4.jpg

That’s good, but I’m going to need clouds if I really want to make this lampshade look sky-esque. For some reason, I thought I’d try and generate some puffy clouds fractally. It became apparent very early on that this was a foolhardy approach, but I messed with it a bit longer than I should simply because it was generating such interesting images.

The method I was fooling around with worked like this: I draw this blurry circle of light, and then within that circle I draw several smaller ones, and within each of those I draw more, on and on, recursively. They get brighter as they get smaller. By varying the parameters – how many circles, how bright, how much smaller they get with each iteration – I come up with a lot of very interesting images. Some look like a relief map of a gorge-ridden desert landscape. Some look like cauliflower. None of them look like clouds.

One of the many fractal non-clouds:

pixelcity_sky1.jpg

Eventually I stop playing around and get back to work. This is very far from my mission parameters. My goal is to sell the scene using simple tricks, and trying to create believable clouds using fractals is the opposite of that. I save the fractal code elsewhere in case I want to play with it again, and devise a simple trick:

I draw my fading circle texture onto the canvas, only I color the circle black. Then I squash it vertically and draw it again, only slightly lighter. The further down the canvas I go, the more I compress my circles vertically. So the circles near the top will be nearly round, but those at the bottom will be nearly a horizontal line. The result:

pixelcity_sky7.jpg

And now I slap that texture over top of the gradient and the stars:

pixelcity_sky5.jpg

This is the way to go. I spend some time fussing with the color parameters: Cloud size, opacity, density, the contrast of the lit underside of the cloud, and the degree to which they flatten out as they approach the bottom of the texture. (The horizon, from the user’s point of view.) Unlike the buildings, these parameters aren’t something I can just plug into the random number spewer and create infinite content. Most of these numbers are tradeoffs, and making it look better one way will diminish it in another. Eventually I decide to stop messing with it:

pixelcity_sky8.jpg

We’re getting close now.

 


 

Procedural City, Part 5: Fixes

By Shamus Posted Monday Apr 20, 2009

Filed under: Programming, Projects 33 comments

The time spent contemplating the program did not go to waste. I was able to correct several things that had been bothering me.

Building Textures

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:

pixelcity_building5.jpg

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:

  1. 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.)
  2. How much (if any) the lid sticks out from the side, forming a ledge.
  3. How tall the lid is, in stories.
  4. If the corners of the building are explicitly windowless.
  5. The grouping of the windows and blank areas on the face of the building.
  6. If the tower gets narrower towards the top.
  7. The window texture used.
  8. 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:

pixelcity_building6.jpg

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.

pixelcity_building7.jpg

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.

pixelcity_building8.jpg

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.

 


 

Nathan “Flutebox” Lee and Beardyman @ Google, London

By Shamus Posted Saturday Apr 18, 2009

Filed under: Movies 21 comments


Link (YouTube)

I actually liked Flutebox better than Beardyman, who seemed to the the headliner, but they’re both talented and inventive.

 


 

Black Sigil Released

By Shamus Posted Friday Apr 17, 2009

Filed under: Video Games 27 comments

Black Sigil: Blade of the Exiled has been released. I intended to write about this sooner but got caught up in the city project. This is the indie game I worked on for several months last year. It’s a very old-school jRPG style game for the Nintendo DS. I’ll have a later post talking about the game and my experience working on it, but I wanted to let you know the game was available now.

EDIT: Delayed. Alas. I’ll write about the game when it actually hits the shelves.

 


 

Stolen Pixels #82: Left 4 Dumb: Part 4

By Shamus Posted Friday Apr 17, 2009

Filed under: Column 20 comments

I just want to point out that the title “Stolen Pixels #82: Left 4 Dumb: Part 4” has way too many numbers in it. To be fair, Valve started it by putting excess numbers in the middle of a title. I’d like to give these comics proper names, but “Stolen Pixels #82: Left 4 Dumb: Part 4: Sweeping Changes” is nigh unreadable. And what if they came out with a sequel? “Stolen Pixels #317: Left 4 Dumb 2: Part 12: Nerf the Pushbroom!”, isn’t a title, it’s an article.

But you could read it anyway.

 


 

Procedural City: Intermission

By Shamus Posted Friday Apr 17, 2009

Filed under: Programming, Projects 20 comments

A malfunctioning back is preventing me from investing more time into the procedural city project. But that’s fine, because I think I’m at the stage where I need to stop and have a jolly good think. Even if I was up for working on it right now, I’m sure I’d just end up writing code that would have to be rewritten or replaced later.

When I began I had some aspects of the project worked out in my mind. Now I’ve distilled those ideas into code, and the next few steps are much more murky. I know if I wait, the ideas will firm up and I’ll get a better idea how to design things. This is one of the reasons coding as a hobby is more fun than coding for a living. Your average boss isn’t going to want you to take a couple of days off to screw around while you design the thing in your head. This is perfectly understandable, but sometimes it’s nice to work at the rate at which you get good ideas instead of at the rate which someone is paying you. I suppose if I was smarter then my ideas would keep up with my schedule. But… if I was smarter I’d probably have a more demanding job for more money. Hm.