Sunday, 28 November 2010

Clothing deformation

So I'm continuing working on completely random and meaningless stuff and I started thinking about the best way to animate clothing, and then started implementing what might just be the worst way possible.
I wanted to make a system where the clothes could have their own rig and their own animation, but could easily be linked to a chacter and follow his movements. Then I got a crazy idea that instead of just linking the rigs, I would skin the clothes dynamicly to a character; that way it would actually be possible to make a character visually undress or get dressed.

So I skinned the clothes to a simple rig, then I created a skinweight map for the character, and used that to find out what joint in the players rig to connect each vertex to based on their current position.
Getting this to work on the pants went well enough but it turned out that taking of a shirt is a lot more complicated. Obviously he had to raise his arms before I could animate the shirt, but the shirts animation had to be relative to the bind pose. The problem then was that if I raised the shoulders in the bindpose, somehow the animations got screwed and the shoulders looked slightly off when in their normal position. I tried a lot of different ways to transform betwen the different bindposes, but nothing really worked. In the end I used a very ugly compromise so the shirt uses the matrices based off the normal bindpose whenever it's in it's default position, but as soon as a it starts moving it uses the other bindpose.

I'd probably be able to make it look a bit better if the exporter supported scaling joints or if I make a more advanced rig for the shirt. Anyway heres the result. The clothing items has a simple animation when he takes them off; basicly just moving up or down and squeezing a bit, they are then dynamicly skinned to the character every frame (all in the vertex shader).

While it does look quite horrible and half broken; I still can't help feeling that it looks absolutly awesome somehow. And of course, with a system to animate people taking their clothes off, I'm one step closer to achieving my lifelong dream of creating the ultimate porno game...

1 comment:

  1. lol, as I was reading this I was like wtf is he going to use this for? that I read the last part LOLed. wait it could be a game where the character takes off his clothes before he enters water or pools.