This blog has moved. Visit Groundswell Games for the latest. Remember to update your bookmarks and RSS feeds.

Friday, November 28, 2008

Morph targets and a disembodied head

It's been a while since I posted something for you to play with.

Well, here you go.

A man's faceIt will take a minute to load (lots of stuff to calculate). Once it does, just play around with the sliders to customize the guy's face. You can click and drag on his face to turn him around. Cool, huh?

Unfortunately, I can't say that I whipped this up after Thanksgiving dinner. Actually I've been working on it for a week or so, trying out different methods of achieving what I wanted -- and some methods of getting nowhere close. Actually, this version is the most complex one I did. The fact that it works is reason enough to post it.

How it works
Now the thrilling explanation. One of the features that Unity lacks at the moment is the ability to handle morph targets (aka blend shapes) imported from 3D tools like Maya or Cheetah. So, the only way to implement them is to code a system by hand. After scouring the Unity forums, I found a script that would handle simple mesh morphs but didn't do anything as complex as multiple blended attributes.

Using the basics of that script, I manged to put together a system that works pretty well. Here's the basic flow of things:

  • To set everything up, I assign the base mesh (3D shape) in Unity, then create a list of attributes that I want to adjust. Each attribute has a reference mesh created by editing the original mesh to get the most extreme version of each facial attribute.
  • When the scene loads, it first stores several pieces of information (this is why it takes a while to load):
    • For each attribute (24 of them in this scene), it builds a list of vertices in the mesh that are affected by that attribute.
    • At the same time it builds a list of offset vectors for each vertex affected by each attribute. This information stores the maximum possible offset for each vertex per attribute. Lots of data building up here...
    • Then we build a list of which attributes affect each vertex. This is the converse of the first list above, and it's necessary to keep the code running smoothly.
  • After all that data has been stored, the default mesh loads along with a bunch of sliders to control the various attributes.
  • Each time a slider is adjusted, we calculate the proper amount to adjust each vertex affected by that attribute. This is done by using a weighted average of all the attributes affecting each vertex in question. By using a weighted average, we can combine attributes like the width and height of the eyes without getting conflicts (this part took me forever to figure out).
  • Once we have the right offset vectors, we adjust the affected vertices by those values and redraw the mesh. Voila!
Optimization
Because there's so much manipulation of individual vertices in this code, it was really hard to optimize. I spent almost the entire day trying to get it to run at an acceptable speed, and I still don't think it's good enough. The main problem is that when a vertex (or group of vertices) is affected by multiple attributes at once, the weighted average becomes harder to figure out and requires more processing juice. I attempted to store offset values rather than recalculating the average every time a vertex is affected, but I couldn't figure it out before dinner. This version runs well enough, so it will have to do.

Oh, and happy (late) Thanksgiving!

EDIT: I posted a new version of the file after getting some serious optimization help from Jamie. It still takes a while to start up (but not as long), and it runs considerably faster once it loads. My code now also morphs the normals as well as the vertex positions, which I had overlooked before.

Tuesday, November 18, 2008

Untold fortunes await

This is the kind of article I don't need to read. It puts crazy thoughts in my head. The article relates the stunning success of a young fellow who developed an iPhone game over the course of four months, put it on the App Store, and made $250,000 in the first two months. Now he's quit is day job, started a company and employs several people. He's living the dream.

The article does point out (a little slowly) that untold fortunes aren't exactly guaranteed. I don't have any serious notions about creating an overnight sensation--though it would be pretty cool. In fact, being the realist that I am, I can think of three big reasons why my path probably won't match his:

  • He designed a puzzle game. Puzzle games have very broad appeal and are great to play for five minutes at a time.
  • He made a game that required minimal art assets (just a few triangles that can flip over). This fact alone probably saved him months of development time.
  • His game was available at the launch of the App Store. This is the big one. The number of games available on the App Store has grown ridiculously fast over the last few months. The difficulty of cutting through the clutter increases with every game that gets added.
I'm not trying to say that puzzle games are easy to make. It's a space that will get crowded really fast, and few have the right addictive qualities. I'm also not that interested in making them. For some reason that will probably doom my game development career before it begins, want to make games that have some element of character and space to them.

The real point probably is that, while there's real money to be made in iPhone gaming, it's going to get harder all the time to get people's attention. But with a great idea and a lot of polish, it just might be possible to create something really special. Success might also take quite a few failures.

Thursday, November 13, 2008

More clout for iPhone gaming

Saw this article about the fact that several game industry heavyweights are throwing their ... weight ... behind iPhone gaming. There's one EA exec that has gotten quite a bit of press the last week or so for saying that Nintendo and Sony should be scared of the possibilities for Apple-based mobile gaming.

The fact that the iPhone isn't a dedicated gaming device doesn't seem to be a problem for these folks -- nor should it be. In fact, the idea that you can carry one device around to occupy every odd minute of your life seems quite appealing to people.

I've been reading about some of the technical limitations of the iPhone, and it definitely seems possible to overcome them. I'm trying to think of it like a retro game development exercise. I'll just pretend I'm developing for the original Playstation or N64.

In case you're wondering, I'm not actively developing for the iPhone, yet. I'm hoping in the next couple of months I'll be up and running. My brother and I are working on a game right now that we're planning to port over, and I have another idea for a game that could be really cool, if I can pull it off. SPUDZOOKA is on the list, too. It might be a good one to practice on, since the game is pretty much done. I would want to add some new levels, though (how long have I been saying that?).

Monday, November 10, 2008

A confession of loyalty betrayed

I have always been an Apple fan. (That's not the confession.)

It wasn't long ago that such a statement would cause listeners' eyes to roll uncontrollably. Often this reflex was accompanied by a sharp exhale of breath that most people would mistake for an impatient sigh laced with sarcasm. Lifelong Apple fans like myself, however, have always been able to recognize the true emotion behind those reactions: jealousy.

Don't bother to deny it -- denial is just part of the friendly game we all play. It's ok; I understand. Now that Apple's cool and Microsoft isn't, I do like saying that I knew that from the beginning, and I told you so, and Mac OS 6 beats Windows 3.1 any day.

All these things are self-evident, and my gloating undoubtedly suits a Mac user admirably. Nevertheless, there is one little problem: I love my Xbox 360.

Maybe it's the allure of hi-def gaming. Or the number of games that appeal to my taste more than the PS3. Or maybe it's the promise of a true all-in-one media center in my living room (not that I've downloaded any TV shows or movies through Xbox Live, yet).

I don't know the reason, but I find, strangely, that I'm excited by the impending arrival of the New Xbox Experience on Nov. 19. Not just a little excited, either -- I'm excited like Steve Jobs is giving a keynote at WWDC. How did this happen?

But there are plenty of things to be excited about, right? I will be able to:

  • Create a Wii-worthy avatar to replace my stupid gamer picture
  • Navigate through thousands of downloadable goodies much faster
  • Stream Netflix movies straight to my TV
  • Some of the Netflix movies are even hi-def
Sure, mostly I'll just be playing games like I always did, but there's something about the new wrapper that has me giddy as a schoolboy. The Netflix streaming itself is pretty awesome, so maybe that's the reason. Netflix is way cooler than Microsoft anyway.

If anybody's interested, here's a review of the New Xbox Experience from Ars Technica.

Wednesday, November 5, 2008

Lament of an anti-social gamer

There was a primer posted on Gamasutra a couple of weeks ago about the growing role of social communities in games (and the challenges of building one that works). It's probably obvious by now that there are huge advantages to building an online social community around games -- give your players a place to compare notes and shoot the breeze with other players, and you've got an almost surefire hit, particularly if the game already has a fanbase. Even games that are entirely played online anyway (say, World of Warcraft) have thriving internet communities because they give players another reason engage with each other while they should be working.

But is it possible to provide too many social options for players? It's a lot of work to set up such things, and there may be a point at which actual gameplay can be sacrificed for the sake of "social" features. The case in point is Spore. I was pumped about Spore before it came out. I bought it within a week after release. It's a great game, and it's revolutionary in several ways, but when you really dig into it, there's not much game there.

The Spore experience is so focused on encouraging players to share their creations with each other that I felt from the beginning as if I were missing half the game because I didn't care about looking at other people's creations. I love that other creations are pulled into my universe automatically, but I haven't spent a single minute looking at sporepedia online or making friends in the online Spore community.

(Full disclosure time: I'm not a heavy user of social media. I get it, and I think it's changing the nature of the internet before our eyes. But I lead quite an anti-social online life.)

It's becoming accepted generally that, if you don't build social features into your game, you better do it online. In fact, one of the suggestions I've heard for indie developers is to focus lots of attention on your online social presence. Make your game about connecting, not just playing, say the experts. They're probably right--all my favorite and most enduring entertainment experiences have thriving communities. My lack of participation doesn't mean it isn't there.

What I'm trying to find, being an ultra-indie, is the right balance. I can't build or support a big-time social platform to supplement my games. Even if I could, it would almost certainly seem incongruous with the scope of the games themselves. Nor can I hope to compete with the big casual game sites (which naturally have full-featured social elements).

Probably, as with most things, the answer is somewhere in the middle. Create a game with in-game social elements (like multiplayer) and then give players a simple way to connect with each other outside the game using existing platforms like Facebook apps or embeddable web site widgets. Guess I'll add those to the list of things to learn.