Home Technical Talk

How to rig and animate cloth/hair in games??

polycounter lvl 10
Offline / Send Message
melviso polycounter lvl 10
Hello All,
I am new here and am really happy to know there is a forum solely for videogame 3d artist/animators/designers.

I am working on an animation project.I am a 2d animator that recently switched to 3d animation but I have long since been familiar with modeliing,uvmapping,rigging and texturing.

I have a model with long hair and a cape and I am really thinking of doing the bones/dynamic ik spline way by using Maya hair to drive the bones that will then deform the hair and cape but my problem is how to prevent the cape or hair from entering the character's mesh.I have studied cutscenes and gameplay of games like heavenly sword, and FFXIII and I noticed that bones were used but they don't go through the character when they move about.

Also saw this:
[ame]http://www.youtube.com/watch?v=vrx1NQJP70U[/ame]


Is there some sort of script or constraint being used to keep the deformed mesh from penetrating into the character as the hair solver collisions works with the hair curve and not the cape or hair geo?

I don't wanna use ncloth cause of the heavy simulation and repeated tweaking.With 3 or 4 curves,running simulation will be far more lighter.

Will appreciate replies from anyone familiar with this aspect.Thanks.

Replies

  • Zpanzer
    Options
    Offline / Send Message
    Zpanzer polycounter lvl 8
    Depending on what your end project will presented in, I would look into cloth simulation even though it's heavy as you mention. The video you presented is a realtime simulation of cloth running on the GPU and most likely using a PhysX solver to do so. Unreal Development Kit has APEX Cloth incorporated, but I don't know friendly this is. If the final result of your project is to be presnted in a game engine and you don't have the time to set up the realtime cloth solver, you might want to do like they do in World of Warcraft, they skin the cloth that is near the different parts of the body to the same bone. And then you add some secondary motion using either bones or helper objects, or that atleast how I would do it.
  • Mark Dygert
    Options
    Offline / Send Message
    That's a very engine specific question there are a lot of ways to do it and there are a lot of reasons for each of those ways. Even within the same engine you might approach it differently based on the game being created and the type of object. There really isn't one solution you take off the shelf and apply that to everything.

    You also have to be careful when watching cut scenes that it isn't pre-rendered and you think its happening in the engine.

    One solution for the heavy simulation time, is to run cloth on a simple object and then skin your final mesh to that object in some way. In max we place points on the simplified cloth object, then snap bones to those points. That way you can capture a sim like quality but you can animate the bones to get the cloth back into a root pose or fix an area the sim behaves poorly on. For the most part the sim takes care of the collision and once its set up its fairly easy to work with.

    Of course that all depends on the engine, how it handles bones, if you can use floating bones, bla bla bla.

    A few games like Alan Wake and LA Noir had specific cloth simulations built into their engines and handled them in different ways.
    http://www.gamasutra.com/view/feature/4383/the_secrets_of_cloth_simulation_in_.php?print=1
  • AnimeAngel
    Options
    Offline / Send Message
    Well hair and capes still seem to be the bain of game development. There is always a lot of fine tuning to get it just right and interpenetration keeps many animators up at night , I am sure.
    I have not done a whole lot of hair and capes myself as I am not an animator, but from my experience working on games, I think the best way to keep it from clipping into things is to set up collision boxes around the character or other objects.
    How this is handled I believe has a lot to do with what engine you are using. Some engines may have their collision solutions while others may need you to create them in your 3d package and export them as separate objects.
    I could be wrong on this but I believe that is how it works. Some of the other animators, such as Mark aka Vig, may have a better insight into how this work.

    edit : lol mark beat me to the post.
  • Demiurg
    Options
    Offline / Send Message
    Demiurg polycounter lvl 6
    Hello all !

    The video in the first post is mine, and I would like to explain how it`s made.
    I hope you excuse my English, I`ll try to explain with simple words.

    - Case:: to make illusion of cloth without simulations. Yes, we can use PhysX cloth, but it is heavy, especially for MMO game with lot of players and NPC`s. So, I search a solution to make good cloth motion only with standard Bones (in 3DSMAX 9).


    - Problem: If I make standard bone rig of this "skirt" (yes, this is a mackintosh, but technically this is "skirt", because only the bottom part moves), with standart controllers, will be a lot of work to animate every of ~15-20 bones. And second - this is secondary animation, and every time you change the human motion (fix something) you need to adjust and skirt animation, by hand ! So - without automatisation this is lot of hard work !

    - Brief decision: Very simple ! I make real cloth simulation in my MAX, loop it, and constrain my Bones to vertices of simulated mesh. So, skirt Bones are driven by some hidden simulated mesh, but the real model is skinned to these Bones and with some skinning work it moves exactly like a simulation. When export animation to the engine, the exporter just sample bone motion, no matter how they are constrained.

    ---- This is brief explanation, "ideology".
    If someone interests in details, I can describe \technically this was a little challenge), but let this be in another post, because it took lot of time to me to write in English - I use diction and check every word, and this is boring... Sorry!
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Thanks for the reply,guys.I am not actually doing it for a game.It is for an animation sequence heavy with fight scenes and the girl is gonna be darting around doing flips and wielding swords about,including summons and she has long hair and a cape.
    Imagine how heavy it will be to run simulation for these animation sequences.Thats why I am opting for dynamic ik splines.I have tried using wire deformers for the cape and hair but that means I would have to animate it manually and that would take time.My major problem is collisions.
    I saw the making of heavenly sword video and they used bones for the hair and it was done in motionbuilder.
    Also saw this in the Hair Technique wiki on polycount:
    HairTechnique?action=AttachFile&do=get&target=tmp.640.hair_ff13-shaded.jpg
    This image is from square enix.It shows how Lightning's hair was rigged for animation.My guess is that they rigged her hair and cape and used dynamic ik spline to simulate the movements.What blows me away is the cape in the game,it moves realistically and still stays in place.

    BTW,Are there tutorial videos that show how to use this methods you have mentioned?
  • Demiurg
    Options
    Offline / Send Message
    Demiurg polycounter lvl 6
    I think in this case bones are used for Rigid Body simulation, something like this:
    [ame]http://www.youtube.com/watch?v=PpwF_30aeyI&feature=related[/ame]


    Advantage of this method is simplicity and speed, which is priority for making game rigs (and this pictures is exactly game rig, i think). Disadvantage is low-quality motion. Quality, which is well enough for game, is not enough for cinematic.

    I should make this with cloth simulation of some proxy-mesh. Common error in simulations is to make sim with high-poly model. This is no need !
    Make some low-poly variant for every strand of hair, just a few polys, with REGULAR topology (this is important, because in real model faces are with different size and this slow down the simulation). Make such "proxy" low - model for the head (deflector in simulation) and simulate only these proxy objects. This is fast and easy. If you are satisfied in simulation, then SkinWrap (Wrap Deformer in Maya) real model to these "proxies".
  • Mark Dygert
    Options
    Offline / Send Message
    Demiurg wrote: »
    Hello all !

    - Brief decision: Very simple ! I make real cloth simulation in my MAX, loop it, and constrain my Bones to vertices of simulated mesh. So, skirt Bones are driven by some hidden simulated mesh, but the real model is skinned to these Bones and with some skinning work it moves exactly like a simulation. When export animation to the engine, the exporter just sample bone motion, no matter how they are constrained.

    ---- This is brief explanation, "ideology".
    If someone interests in details, I can describe \technically this was a little challenge), but let this be in another post, because it took lot of time to me to write in English - I use diction and check every word, and this is boring... Sorry!
    A while back I detailed the process of getting bones to follow a cloth sim.
    http://www.polycount.com/forum/showpost.php?p=1021761&postcount=17
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    So sorry guys,I really appreciate the replies so far.I use Maya 2011.Are there tutorials for Maya?These ones are for 3DMAX.

    Mark,seems like you are a pro in this aspect.If its not too much trouble,you should do a tutorial video detailing this technique and send to all these tutorial websites with link to your original website.You are very talented.

    Tutorial videos are self explanatory.If possible,in Maya.It will go a long way in helping us,newbies.
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Trying to figure it out.

    So I should create a high cloth simulation of the cape and create like three bones on the cloth and bake the simulation to the bones and then use the bones to drive the new cape and hide the initial simulated cloth or delete it?
    Demiurg

    I think I am gonna try it,using a low res mesh of the cape and use it as a warp deformer to drive the high res one.Thanks.

    Just wish Maya hair had better geo collisions like ncloth.All you have are collision spheres.I am thinking of using Maya dynamic curve to simulate the cloth and make the cloth ncloth and turn off everything except the collisions.The curve will drive the cape movements and the ncloth solver handles collisions.That will reduce the heavy simulations.
  • Demiurg
    Options
    Offline / Send Message
    Demiurg polycounter lvl 6
    Forget about bones if you need quality. Just make simulation with low-poly model, and use this simulated model to drive the real high-poly model (with Wrap Deformer).


    - @ Mark Dygert - really good explanation! I use the same way, with only difference I use Bones, not Dummys, and create automatically these Points and attach them to selected vertices via macroscript. I would like to make add to your great tutorial with this macroscript:
    http://dox.bg/files/dw?a=33e28953bd
    -- save it to your "..\enu\UI\macroscripts" - directory and search it in category "Masthead Tools".
    Script work ONLY with Edit Mesh (sorry for that, but Attachment Constraint uses mesh-faces, not Poly-faces), so you need to add one "Mesh Select" modifier if you work with Poly.
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Thanks Demiurg,I will try it out.
  • e-freak
    Options
    Offline / Send Message
    Are you doing this for Cutscenes/non Interactive NPC Animations or for Gameplay (AI/Player controlled)?
  • Scythe
    Options
    Offline / Send Message
    Scythe greentooth
    Well, as I was eye above the shoulder of the animator on the last game I worked on, they used a pretty nifty way of animating capes.
    If I remember correctly, they were rigging the cape with bones, then use cloth simulations on the cape so it'd move accordingly to it's mass&stuff, and then they'd project the key of the cloth simulation onto the rigged cape =) Hopes that helps :)

    @Demiurg : Your video seems awfully like the hair rigging used on Star Ocean : The last hope, It'd behave the same way. Pretty cool and easy way to animate some hair (ponytail and such) for them to move accordingly to the character's animation :

    http://youtu.be/aweFsvzjkLc

    (Sorry for the title of the video, it's the best one I could find in which you see her hair...even though it's focused on her butt)
    Or maybe that's just done with physics~

    Anyway as it has been said before, it mostly depends on the game engine
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Thanks for the info,scythe.I think for just cutscenes,baking to bones doesn't matter cause the baking is for a particular series of movement so the game engine doesn't have to calculate cloth movements or if you bake to the bones and you animate a different movement,will the bones move with that movement or you have to do another simulation and bake to bones?

    @e-freak
    For cutscenes,but I am trying to keep things light on simulations and textures.So its gonna look like in game cutscenes.I will probably use After effects to composite the scenes and add effects to make it look lifelike or realistic like a prerendered animation sequence.
  • Scythe
    Options
    Offline / Send Message
    Scythe greentooth
    Well, After you baked your simulation to your bones, you can still moves them or do anything as you want, since from that point on, it'll react like a normal animation.
    The point of the simulation is just for giving a realistic look to it, but nothing keeps you from modifying afterward and so on. (Especially if you baked some capes and clothes and they keeps getting into the character's mesh, then you can correct it so it won't)

    Hopes' that helps :)
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Thanks scythe.

    Guys,I wanna ask:
    In rigging using Maya,is it possible to tweak the vertices in a particular possition for say the shoulder and then move the bones to another position and tweak the vertices so when you move the shoulder between those two positions the vertices stay within those two places.This is possible in Mudbox.

    In Maya,you have to paint skin weights.I am having MEGA-LUTIVE problem with the shoulder area of my model and I used this method:I used the no 2.method whenever I try to carry the arms up like hanging from a pole with the model,the underarm bulges out.I have tried to paint the weights towards the chest bones so it goes in but nope.Can't we just tweak points instead like in Mudbox when you move the part of the mesh in as you use the pose tools on your model??
    ShoulderTopology?action=AttachFile&do=get&target=PiorOberson_shoulder-compare.jpg
  • Demiurg
    Options
    Offline / Send Message
    Demiurg polycounter lvl 6
    melviso wrote: »
    Guys,I wanna ask:
    In rigging using Maya,is it possible to tweak the vertices in a particular possition for say the shoulder and then move the bones to another position and tweak the vertices so when you move the shoulder between those two positions the vertices stay within those two places.This is possible in Mudbox.

    In MAX we have modifier "Skin Morph" who do this - when bones moved to definite position, then vertices moved to definite morph target. You can do the same in Maya, with few Blend Shapes, connected to Utility Nodes via Connection Editor, or Set Driven Key (sorry, I`m not a Maya user).
    About the topology - I work with first type, but I made a stretchy bones for more important muscles (pseudo muscle simulation). Even if the character is not so muscular, these bones just keep volumes of muscles (shoulders - deltoid muscles).
  • Mark Dygert
    Options
    Offline / Send Message
    Demiurg wrote: »
    In MAX we have modifier "Skin Morph" who do this - when bones moved to definite position, then vertices moved to definite morph target. You can do the same in Maya, with few Blend Shapes, connected to Utility Nodes via Connection Editor, or Set Driven Key (sorry, I`m not a Maya user).
    About the topology - I work with first type, but I made a stretchy bones for more important muscles (pseudo muscle simulation). Even if the character is not so muscular, these bones just keep volumes of muscles (shoulders - deltoids muscles).

    In the skin modifier max also has, joint angle deformer, Bulge Angle Deformer and morph angle deformer. These do pretty much what skin morph does but work inside of skin instead of on top of it so they're a little faster and each does slightly different effects. They are all pretty straight forward to use like skin morph, pose your joint at the start pose, pose it at the end, arrange the verts to look good and off you go.

    I think in Maya they are called "corrective blendshapes" and you have to hook them up like Demiurg described. You can do it manually like that in max using either wire parameters or reaction manager (the direct equivalent to driven keys) but you really don't need to.

    There are probably some tools to make them as quickly and easily as in max with skin morph or the joint angle deformers in skin. So you should probably poke around creative crash or some dedicated rigging/skinning tools.

    Shoulders are always a nightmare so don't feel bad, they give everyone a bad time. As for the topoplogy they both seem fine I've worked with both set ups. You might run into a problem in the shoulder blades because its a little sparse on geometry back there but it depends on the game, the character and the type of rigging allowed. Games get a bad rap for having bad weighting and horrible low joint counts but that's what you get when your team wants to spend its tech budget on making sure you can see your reflection on a candy wrapper as it floats on a beautiful water shader...
  • monster
    Options
    Offline / Send Message
    monster polycounter
    You'll get a pretty good results with a couple of twist bones on each shoulder, and your programmers won't laugh at you when you ask for corrective blendshapes in real time.
  • Mark Dygert
    Options
    Offline / Send Message
    True if this is for a game forget about corrective shapes. Also the amount of extra rigging and tweaking greatly depends on the animations the character will be doing. If they are holding a gun and their arms never go above their head then you don't have to worry too much about the shoulders. Some people tell you to adjust skin weights with the rig in extreme poses but those should be relative to the range of animations.

    Also remember that when you lift the arms above the head it's important to also lift the clavicle (shoulder bone) it can also help greatly if the clav is setup to roll as well as pivot. And like monster pointed out a twist bone can also help with the candy wrapper effect.
  • Demiurg
    Options
    Offline / Send Message
    Demiurg polycounter lvl 6
    Here is a simple muscle rig. On the arm have Twist Bones, and Stretchy Bones for muscles:

    024838341-big.jpg
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Thanks for all the replies,guys.I just wish you guys were using Maya.Seems like 3dmax is more widely used for games while Maya for movies.

    @Demiurg & Dygert,I googled corrective blendshapes.Its kinda technical but I think this is the right way to go.I don't think Maya has all this tools you mentioned since I think Maya is tailored towards movies.
    Since I am working on a cutscene,I am gonna try it out.
    @monster
    Thank goodness,I am not working on a game but isn't blendshapes used for facial animation in games??


    Just found out about changing the deformation order by putting the tweak at the top of your skin cluster in the input window,you can then directly modify the vertices of the mesh,so I am thinking,move the joint to extreme positions,make the vertices right and save as a blendshape so,voila animation begins.Seems like a lot of blendshapes though.
    Found a space deformation script,will check it out.
  • monster
    Options
    Offline / Send Message
    monster polycounter
    Your post title says "...in games" so I assumed the shoulder problem was for games as well.

    The twist bones are still a valid option for cinematic work, and can make creating the corrective blendshapes easier.

    Blend shapes and Morph Targets are used in game, but they are usually driven by preset animation data and not by dynamic joint movement.
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Thanks a lot,guys.
    UPDATE:
    I tried the corrective blendshape with the model,encountered a lot of problems,then I realized the target model must be in the bindpose for it to work without problems.So I tweaked the shoulder area of the target model while observing how the tweak affects the rigged model in various positions.The shoulder looks good now on the rigged model at different positions including upwards(didn't use driven keys cause shoulder has like 4 different rotations). I am using IK for the shoulder to the hand.Should I remove the ik and animate the shoulder with FK?
    Another problem is I can't paint skin weights on my rigged model anymore after this.Was I suppose to complete painting the skin weights for all the body parts first before using corrective blendshapes?
    I am kinda getting frustrated.In 2d animation,all I needed to do was draw and colour my frames but I know I have to be patient and see this through cause when everything is set,animation is very easy and there is no need to draw hundred frames for a camera shot.Imagine drawing each frame for a 15 mins animation and detailing it with colour at 24 fps.
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Guys,Its working now.The shoulder finally deforms well.Thanks a lot,finally got the hang of corrective blendshapes.By the way,I saw this on youtube:

    [ame]http://www.youtube.com/watch?v=bgZTWDetoYc[/ame]

    The script used here is called Hyper real corrective shape script by Eric Miller.
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    Demiurg wrote: »
    Here is a simple muscle rig. On the arm have Twist Bones, and Stretchy Bones for muscles:

    024838341-big.jpg

    Demiurg,so you don't use corrective blendshapes for your rigging?I have been running into problems with my blendshaping.Getting dependency graph errors.Did you smooth bind it or use rigid binding?
    I am gonna try your style.I saw this video:
    http://vimeo.com/20228514

    In the footage,It seems every vertices has stretch bones attached to them.Seems like a lot of work but the results are really good.

    I wonder how the character in Uncharted was rigged.His arm moving upwards doesn't show any bad deformations.Wonder what I am doing wrong.

    Does anyone know how stretchy bones can be created in Maya?


    EDIT:No worries,will do the research on my own,probably asking too much unnecessary questions.
  • melviso
    Options
    Offline / Send Message
    melviso polycounter lvl 10
    A decision has been reached.2D animation will be used for the cutscene,maybe 3d elements for the environment .That means it would be easier to pull off free flowing hair and cape movements and believable explosion and spells and no worries about bad skin deformations and uncanny facial emotions.

    Thanks for the help.
Sign In or Register to comment.