Faking hair/cloth physics using vertex animation

I wanted to know if it’s possible to fake physics for hair (Short-medium lenght hair) using WPO in the vertex shader? At the moment, I have the SimpleGrassWind hooked up to my hair shader, And the intensity of the wind changes based on the movement of the character. Does anyone have any ideas on how to add a bit of drag on the longer strands of hair to simulate it being effected by the velocity and direction of the player movement? Or maybe even simulate a little bounce as well (maybe tied to the movement of the Head socket or something). Maybe something usable for short pieces of fabric or string hanging off the characters clothes even.

I intend to use this for a mobile game, so Apex is out of the question.

implementing this purely using WPO will give you a hard time.
for one your hair will not collide with the body, so you’ll see the hair going through the head and shoulders. you’d need to fake the collisions somehow.
second is the fact that to add some kind of drag/inertia from the player movement, you have to inject it manually because the shader doesn’t store the position of the previous frame. injecting the player’s velocity as a vector param would give you a start into that (you push the vertices into the opposite position), but you’d need to add some sort of blending that will make that push stronger on the longer parts of the hair and not affect those parts close to head.
then of course injecting only the player’s velocity would make the effect too uniform so you’d need some other method to add secondary animation (i.e. inertia and rebounds), so it doesnt just look like a solid piece of wood

usually for limiting hardware like mobile the common way is to just animate the hair using bones, and on somewhat more forgiving hardware driving it with rigidbodies (PhAT, not Apex) can be made to work. but I’ve always been curious if a WPO approach would look good enough if some effort is put into it. So I’m looking forward to what you can come up with :slight_smile:

Thanks for that. I had similar ideas for the effect. I’m still working on the final character mesh so once i’m done, ill try them out and share the results. I was thinking i could use the vector param to offset direction of the hair based on the character movement and direction. Maybe could also use VInterp to get a smooth transition with the transition time hooked up to speed. Lot to fiddle around with. Will update as I go. Also, collision would be an issue, but im working on shorter hair, so should be fine. Additionally, I could also control the hair displacement with the vertex color too.

So far all i managed to do was just increase the wind intensity as the character moves… which actually looks rather believable, but would be cool of we could see a few strands fly up as the character falls, etc. It’s all in the fine details :wink:

Natalie Burke, a technical artist that once worked with Bungie on Destiny, gave a really good talk about this at GDC a few years ago. Unfortunately, the video of the talk is locked up in the GDC vault which you can only gain access to by purchasing a licence or a pass to the GDC conference. Here is a link to the PDF which is available in the vault for free:

It essentially talks about how animating hair and cloth with vertex offsets is a really good idea from a technical standpoint as it removes the necessity for bones (joints) for many different hairstyles and various character accessories. She goes over how she used painting of vertex colors to store and control different aspects of the animations, such as drag, timing, and follow through. She goes over how they used a sin or cosine to oscillate the hair as the player moves and hooks up the intensity based on the velocity of the character. That’s about all I can remember, but maybe you can learn something else from the PDF.

So, in short, yes it is possible to simulate hair or cloth animation using the vertex shader and it is actually a good idea especially if you are going to have a lot of content that you don’t want to have to animate with bones.

The problem is production time.
AAA companies can hire a guy just to setup these shaders on characters one by one for the next 4 years, but most studios need less involved solutions.

Holy hell I need to watch this video.

Use vertex colors to store data about stiffness and max offsets. You can avoid collisions this way. Simply grayscale color can this vertex bend might be enough. If vertex shader only does minor movement and you also add some bones to drive larger scale movement it might look good enough.