Link (YouTube) |
I actually liked Flutebox better than Beardyman, who seemed to the the headliner, but they’re both talented and inventive.
Link (YouTube) |
I actually liked Flutebox better than Beardyman, who seemed to the the headliner, but they’re both talented and inventive.
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.
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.
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.
Gamestop violated the street date for Stardock’s new game, Demigod. They put it out a week early, just before Easter weekend. Stardock employees were just coming off of crunch mode from finishing the game, and were looking forward to the nice holiday weekend. Instead, they had to come in and rush to get the multiplayer servers up and running to handle the incoming flood.
This happened a week ago, obviously. I’ve been waiting for some kind of response from Gamestop, but they have been giving everyone “no comment”. Of course, this is all “old news” to the fast-moving gaming press, and so I assume the story is over. Gamestop is never going to say anything about this or even apologize. This hurt Stardock, but it also hurt the gamers who bought the game and who couldn’t play online because the servers weren’t up yet. Gamestop doesn’t even have the decency to come out and give one of those boilerplate non-answers like companies do when they make a mess in public. You know, “We regret that this bad thing happened [without accepting blame or admitting our error] and we’re conducting an internal investigation [which we will keep private and never reveal how this happened or why] and thanks for being our customers [and please don’t sell our stock] because we’re dedicated to quality and professionalism and that kind of stuff.” I would consider this to be the most basic thing to do for any company attempting to to uphold the basic pretense that they aren’t just complete assholes.
Setting up the World
One of the interesting decisions that a programmer must make at the start of a 3D project is figuring out what scale to work in, because the renderer doesn’t care. Perhaps you want to set things up so that nearby things are a unit away, and the stuff in the distance is 100,000 units away. Or nearby is 0.00001 and far is 0.0001. It’s up to you to pick a scale and to decide what the arbitrary units mean. Are you working in meters? Feet? Cubits? Fathoms? The effective range of an African swallow carrying a coconut? In Unreal Tournament, characters were around 160 units tall. (I think that the intent was for 128 units to = 1 meter.) In my day job, we work with a system where 1 unit = 1 meter.
While the renderer doesn’t care, it’s important to devise a system that makes sense to programmers and artists so that making content is as easy as possible. If you make something like 1 unit = 2.333 meters, then your artist making a 1.5 meter object is going to use a calculator all day and then spend their evenings plotting how they plan to conceal the body after they murder you. Perhaps 1 unit = 1 kilometer seems reasonable, but making furniture that’s 0.0005 tall is going to be really annoying.
In this program, I’ve decided to eschew using real-world measurements and adopt an arbitrary system of measurement where 1 unit = 1 window. A building that’s 20 units wide will have 20 windows across its face*. 1 unit will also equal 1 traffic lane, so a road 5 units wide will be 5 lanes. Is the typical building window really the same width as a traffic lane? I don’t know, but I’m betting it’s close enough to look believable from a vantage point over the city, which is how the place will be viewed.
* And by “window” I mean an 8×8 little square of pixels. I might have black lines in the space to make that square look like (say) two windows side-by-side, but it’s still a window as far as the program is concerned.
This scale will make it easy to track how I’m using land. I allocate space for my city: 1024 x 1024. According to Wikipedia, a U.S. traffic lane is 12 feet which works out to about 4 meters. So my city will be about 4 kilometers on a side, or ~16Km2 and have just over a million individual 4-meter plots that can be assigned as space for buildings or streets.
One thing you end up doing all the time in programming is subdividing things. Searching, sorting, and grouping things usually involves taking whatever stuff you’ve got and cutting the group in half until it’s found, sorted, or organized. Let’s take a group of 1,000 things and repeatedly divide it in half and see how it goes:
1,000, 500, 250, 125, 62.5, 31.25, 15.625, 7.8125, 3.90625, 1.953125, 0.9765625
Now let’s try it with 1,024:
1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1
But hey, we have the same number of numeric digits as we have fingers, and that’s pretty awesome, right?
City Planning
So I take my city and mark areas of it as “streets”. The streets will be invisible in the final version, but I’m rendering them here as blue lines so I can see what I’m doing.
Now I place 20 big impressive skyscrapers in the middle area of the map. These are buildings with a large footprint and they range from 45 to 55 units tall. (And since units are windows, that’s how many stories tall they are.
Next I scatter around a few dozen smaller buildings. These are just as elaborate as the last batch, but these range from 25 to 35 stories tall.
And finally I fill in the remaining empty space with simple cube buildings.
4,752 buildings. The framerate is still shockingly high considering what I’m asking of the GPU. Still, I’m well under 100 FPS now and I’m betting this would be unacceptably choppy on low-end hardware. On the other hand, I have made no effort to optimize things yet. I don’t even know where the current bottleneck is. That will come in a later step, when I have a little more of the technology written.
I try turning off the dev background and the blue “roads” and seeing what it looks like. Disappointingly, the place looks a little… homogeneous:
Looking back to my reference pictures, I notice that each building seems to have its own color. This is either due to the color of the interior lights, the color of the interior stuff like walls and carpeting, or the tint of the windows. In any case, each building has a slightly different tint. I pick a narrow band of hues and apply them to each building:
It’s hard to see in this screenshot, but the overall effect is pretty striking. It adds another layer of randomness to the world, so that even if two adjacent buildings happen to be using the same texture, they’ll likely be different colors. COUNTERPOINT: Uh, in the middle of this screenshot are 3 buildings the same texture and color. Ugh.
I cruise around the city and take notes:
We’re probably 15 or so hours into this 30 hour adventure. Still on my to-do list:
Buildings
In my previous step I cranked out some plausible textures to go on my buildings. But this next step takes a bit of audacity, since I’m going to need to write a program to engage in architecture. Talented architects get paid huge sums of money to design buildings. It’s a complex and highly creative process, and it would be insane to think I could just simulate all of that cognitive work with a a few hundred lines of code written in the space of an evening. Particularly since my ignorance of the subject is nearly all-encompassing.
Still, I’ve got some Google’d pictures of buildings and stuff. Let’s see how this goes.
Luckily, I don’t really need to duplicate proper architectural work. For the more classic skyscrapers, a lot of the really artistic stuff goes into the surface of the building in the form of fancy stonework, and that sort of detail (or lack thereof) will be obscured by darkness. Hopefully I can simply present the outline of such a building and the viewer will fill in those details based on previous experience.
For more modern buildings, the process is even simpler. No offense intended towards the people who design those buildings, but the really sleek (to my eye) modern stuff is little more than simple geometric shapes. In either case, all I need to do is come up with a simple set of rules that will lead to a building-ish shape.
Blocky Buildings
1. Starting on the ground, produce a rectangular region that a) fits within the building footprint and b) contains the exact center of the building somewhere within its area. This rectangle is extruded up to the maximum building height.
2. Make another rectangle using the same rules as before, with the additional limitation that at least one of the sides of the rectangle must protrude from the center further than any of the previous ones. (Otherwise it would simply be hidden within the previous blocks. Extrude the rectangle from the base up to a height some random value less than the previous one.
3. Repeat step 2 until we hit some limit of tiers, the building footprint is filled, or we get to the bottom.
Rounded Modern Buildings
There is some ugly distortion on the top of the building, the result of screwy texture mapping. I’m still thinking about adding some sort of cap piece to the tops of buildings at a later point. I’m not sure what kind of speed / polygons tradeoffs I’ll be up against, so I’ll leave the distortion in place and revisit it later.
Classic Buildings
It sucks. It just doesn’t look like a real building. I experiment with the dimensions of the building, adding ledges, changing the size of the spike, and a few other tricks. None of them really help. My approach is fundamentally flawed, most likely due to my lack of understanding.
I study the reference pictures again. Eventually I realize that the problem isn’t with the actual shape, the problem is with the shape suggested by the windows. Buildings like this one have stonework on the corners and in long vertical stripes between the windows, and I haven’t left any room for that sort of thing. It’s all windows, edge-to-edge.
I could make texture with those gaps built in. I could leave (say) every other column of windows black, but then I’d have a texture for a specific building type. I very much wanted a completely mix-n-match system, both for the ease of coding and also for the greater variety. Worse, buildings of different dimensions might need different specific textures. Instead of wrapping an arbitrary texture around a building, I’ll have to make special textures and make them line up just right. This is needlessly complex and inelegant.
I decide to shelve this issue until I get a bit more done. These buildings will stay for now, but they will have to go before the end.
Cube Buildings
My plan is to have a few showy skyscrapers sprinkled around the city. Everything else is to be simple cube buildings of varying dimensions. I don’t think I’ll waste page space showing you a picture of a cube. I doubt you need help visualizing it.
Other Buildings
I’d wanted a few more types of building, but I think I need to see how it all looks together. Once I can see the big panoramic view of the city I’ll consider adding more building types.
Next up is the big step: City planning. I’ll jam a bunch of buildings into the scene and see how they look and how fast it runs, and then reassess.
Back in 1999, I rode the dot-com bubble. Got rich. Worked hard. Went crazy. Turned poor. It was fun.
How does image compression work, and why does it create those ugly spots all over some videos and not others?
A breakdown of how this game faltered when the franchise was given to a different studio.
The story of me. If you're looking for a picture of what it was like growing up in the seventies, then this is for you.
His problem isn't that he's dumb, the problem is that he bends the world he inhabits.
A look back at one of my favorite games. The gameplay was stellar, but the underlying story was clumsy and oddly constructed.
Ever wonder how seemingly sane people can hate popular games? It can happen!
Ever wondered what's in all those quest boxes you've never bothered to read? Get ready: They're more insane than you might expect.
What is this silly word, why did some people get so irritated by it, and why did it fall out of use?
Here is how I'd conquer the game-publishing business. (Hint: NOT by copying EA, 2K, Activision, Take-Two, or Ubisoft.)