Sunday, May 30, 2010

Gish is open sourced

The greatest performance improvement of all is when a system goes from not-working to working.
-- John Ousterhout
 

Today Cryptic Sea released the source code to Gish after pledging to do so for the Humble Indie Bundle. This is, in a word, frigging awesome!

Wait, that's two words... but that's okay because that's how cool it is!

For those of you unaware (which is to your detriment, I assure you!) Gish is a brilliant little indie platforming game involving a ball of tar, some really weird enemies, a glitchy physics engine, and some really simple multiplayer. That may not sound like much, but this game has actually gotten my friends and I kicked out of a LAN party before because we were laughing too hard. (True story! Embarrassing corollary: the LAN party was hosted at my house. The kicking was done by my wife.) It's available on Steam, and is worth whatever price they're asking at the moment.

At the very least you should check out the trailer.

Now, that's all well and good but what I actually wanted to talk about was the source code. It doesn't take long after beginning to browse through the code to see that the quality of the code is, frankly, atrocious. Magic numbers everywhere, very little in the way of abstraction, little to no comments. In short, it's everything that your CS teacher would have flunked you for.

And this is a good thing!

Why? Primarily because I think that there are a lot of very capable developers out there who will never, ever finish a personal project of this magnitude because we get too caught up in the structure of it all. After all, what use is a graphics engine if it doesn't have a completely abstracted, plugin capable shader system with a graphical designer, right? I've seen indie projects fail time and time again because the developers behind them spent an awful lot of time carefully constructing an "engine" but very little time actually making, you know, a game. Seriously, the Gamedev.net forums are full of 'em! It's kinda sad.

Which is why I think that the Gish code is great. Because it's a project that got finished! Who cares if the code sucks, it's making it's creators money right now. It's being played by gamers right now! How many indie developers can really say that?

So often the code we interact with takes the form of either:

A) A library, whose interface was agonized over and revised by multiple contributors to ensure that it's usable in the most abstract of scenarios or...

B) Some large, popular project like Quake 3 that gets open sourced after years of use by AAA studios that have beat it into shape, and was designed to be reusable from the get go anyway.

And sure, these projects have their quirks and oddities and funny variable names, but they still represent something that is reasonably polished, mostly reusable, and carefully prepped for consumption by others. That can taint our perception of what all code should look like.

The Gish code has very little of that. The creators essentially plucked the code off their hard drive and dropped it in our laps. Not much there in the way of polish. It does one thing and one thing only: Gish. It's not always pretty how it does it, either. But it works, and it shipped. And that is the single most important milestone that any chunk of code can ever attain. Everything else is just a bonus. Gish illustrates that beautifully by allowing itself to be ugly.

Now, am I saying to throw good design to the wind? No, not in the slightest. If nothing else it can save you a great deal of heartache if three months down the road you suddenly decide that gravity needs to be just a smidge stronger and you had the foresight to define it in a constant instead of using magic numbers everywhere. But we should never, EVER allow an overabundance of design to become a roadblock to the finished product.

Thursday, May 27, 2010

WebGL and Spore Critters

You know what's really lame? Blogs that have one post from two years ago that says: "Hi! I'm _____ and this is my blog and I'm gonna post on it every day!" Well, I'm bound and determined to make sure this blog isn't one of those. To that end, I've decided that if I do lose interest after one post, I may as well make it a good one. So... WebGL!

I've been on an HTML 5 kick recently. (I find that funny because I started out my programming career as a web developer for small internet marketing company. At the time I thought of it as just a stepping stone before I got to do "real code". Now I do "real code" at work every day and I can't wait to go home and play with my HTML!) I don't really care to go into an in-depth analysis of HTML 5 here, there's a billion other sites out there that do that. But one of the cooler bits that has come out of the whole HTML revamp is WebGL. As the name suggests, it's basically just OpenGL in a web page driven by javascript without plugins.

No, wait, I don't think you got that: OpenGL. In a web page. Javascript. No Plugins!

If you don't think that the above idea is awesome, get off my blog! For the rest of you, read on for demonstrations of said awesomeness.

I have a lot of random topics that I want to hit on in the future related to WebGL (performance, matrix libraries, shader organization, etc.) but for the time being you'll have to be content with a little demo. It's based off one of the earlier WebGL demos that appeared online, which displayed a critter exported from Spore in all his unlit, flat textured glory. On the page it mentions that the rendering is omitting the normal mapping and specular information provided with the model and encourages improvements. So I did:

[Update: This was easily the worst demo on the site, and hasn't actually been functioning for well over a year. I've felt it was best to take it down and spare the bandwidth. Sorry!]

Now, for most of you reading this any time near the original posting date, the demo above probably won't work. WebGL is still considered to be very experimental, and is typically disabled by default even if your browser supports it. Try it anyway, since it will point you in the right direction if it can't load properly.

For my version I used next to no code from the original (though I did lift the model, hope no-one minds!). Primarly, the Collada parser was re-written to be a bit more robust and generic (though mine is still extremely limited! Collada is a very complex format.) That said, there are still a great many things I would like to improve, but for the time being it's very fun just to get it up and running.

Enjoy!