Home Technical Talk

Cloth in games ?

Hello everybody ! I'm new here , however i reading forum for a long time . And i have a question about cloth animation in real time , i have a character who's dressing a big apron (like butchers or so ) . I gonna rig him , but i wanna that apron can be animated then , at least a back and forth moving , don't remember many games with that stuff , but if you remember that cloak in Soul Reaver series , how it moving , it was done with bones ? . I've searched here on forums and in other places , but didn't find any lessons . I know nothing about cloth simulation in games , so can someone explain the whole idea how it going ? Thank you all !

Replies

  • Mark Dygert
    Options
    Offline / Send Message
    I could be a dinosaur but real time cloth doesn't happen that often, and hardly ever on characters. Most of the cloth you see is being cheated with well placed bones.

    There are a few tutorials floating around that have bones follow cloth dynamics you set up and run in the 3D app of your choice, but they still relay on well placed bones.
  • dnorth
    Options
    Offline / Send Message
    dnorth polycounter lvl 18
    Simple cloth sim is possible in games. One of our titles here at work uses it, but it requires a pretty big engineering investment, a lot of troubleshooting, and I think it really is only worth it for A) something like you mentioned where the main character has some important design element that really calls for the sim, or B) something like a sports title where it's going to effect all the basketaball player's shorts, for example.

    For a butcher's apron on a one-off character, I would just use bones. Depending on what you're doing with him, you could either animate it by hand or potentially create a sim or simple delay of some kind and then bake that to the apron bones.
  • MoP
    Options
    Offline / Send Message
    MoP polycounter lvl 18
    The cloth in Assassin's Creed was pretty nice, and I seem to recall it was done with bones.
  • Rob Galanakis
    Options
    Offline / Send Message
    Cloth sim is pretty popular nowadays. It can either be done as cloth or as bones. Lots of the 'cloth sim' you see, such as basketball shorts or shirts on arms, is procedurally driven bone animation from the character's bone information (driven by ragdoll or keyframes or whatever). Cloth sim is definitely doable but it is still easier to deal with bones that behave as physical objects, whether you make them behave dynamically in your DCC app or set them up to behave physically (or constrain dynamically and be driven by rotations, etc) in your engine.
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    UT3 has a cloth sim based around bones like prof420 mentions. bones denote pivot points, physics asset defines collision shapes, character definition defines what bones are to be cloth simed.
    Works pretty well on everything I've seen in game.
  • Rick Stirling
    Options
    Offline / Send Message
    Rick Stirling polycounter lvl 18
    Real cloth sim is still pretty expensive, but a lot of companies are throwing more resources at it to try and get something that is closer to real time cloth.

    Rockstar Table Tennis on the360 used real time cloth for the players clothing (and POSSIBLY the net), but anecdotally I've heard that used an entire core for processing.
  • Dunric
    Options
    Offline / Send Message
    OK . So , bones can be a good solution in my case , and if someone know where i can get samples , maybe open source models from games , just wanna see how it realized . However sometimes game engine may have bones count . And , what about morphing ?
  • TWilson
    Options
    Offline / Send Message
    TWilson polycounter lvl 18
    I've tried morph targets before and I don't recommend it. It's hard to avoid oddities from the morph target fighting with the bone weighting. Since you have to weight the cloth to bones anyway so that it moves properly with your character to begin with.

    I recommend bones as well but make sure you speak with your animation programmers. You don't want to require a static pose between each animation. So you'll require some good animation coding. A combination of physics + bones = win
  • Blaizer
    Options
    Offline / Send Message
    Blaizer interpolator
    Yeah, bones is the fast and better solution for some kind of cloths (capes, skirts, etc.), but not all. 3D game models are still so rigid.
  • Richard Kain
    Options
    Offline / Send Message
    Richard Kain polycounter lvl 18
    A lot of the big-name animation packages now feature cloth animation support, even on animated characters. Do keep in mind that most in-game cloth support is going to require some level of programming, as most current game engines are not built to take advantage of it. If you aren't working on your own game engine, or don't know how to code for an existing game engine, than stick with bone animations.

    I think that Havok's latest update includes in-game cloth animation for animated characters.
  • arshlevon
    Options
    Offline / Send Message
    arshlevon polycounter lvl 18
    bones are really just points in space that move. we have put bones on the surface of a piece of high rez cloth, bind the joints to verts on the cloth,run a cloth sim in maya, then rig our real time mesh on the joints. when we export it looks like a fancy cloth sim but its really just bone animation. we have cloth sim stuff too, but its really expensive and not that useful unless its interactive with gameplay. also maya n cloth produces much better results than any realtime solution. this only really works if you have animation blending in your engine, if it just cuts abruptly from one animation to another it will look bad going from one animation to another.
  • pior
    Options
    Offline / Send Message
    pior grand marshal polycounter
    Yup, I saw what Arsh mentionned being done. (was sitting next to the guy doing the rig actually haha). It looks surprinsingly good even with not too many bone 'points'.
  • adam crockett
    Options
    Offline / Send Message
    adam crockett polycounter lvl 19
    I wanted to resurrect this thread for a moment to discuss another solution.

    Why not simulate your cloth motion in your 3d app, then bake that into the geometry using a point cache solution. Then export that motion into your game engine?

    Has anyone tried this, or can you think of a reason not to do it?
  • Mark Dygert
    Options
    Offline / Send Message
    Point cache solutions get expensive really quickly, aren't dynamic and won't interact with anything in real time. It's much less labor and resource intensive to rig bones to a cloth sim. The result is the same, (canned cloth anim). If you're going to do point cache data might as well spend it on something that might make a dramatic impact like facial animation, but even then the same tricks can be applied... so...
  • adam crockett
    Options
    Offline / Send Message
    adam crockett polycounter lvl 19
    You may be right about the expense of a point cache export, I dont know. I'll find out soon though, after these tests Im doing. (the gr2 files I've exported in early tests so far range from 1-4mb)

    However, in my experience, rigging cloth to bones is no trivial exercise. Its really labor intensive in fact, unless Im just doing it wrong. Do you know of an efficient method of rigging cloth with bones? A dress, for example, I'd hang a chain of bones in front of and behind each leg, and one off to each side, with a spline IK controller running a cloth sim on the spline. Envelopes almost never give me the results I need, so I usually end up weighting each vert by hand, hence the labor!

    For this game we're working on, I'm not interested in real time dynamics or interactions with anything, I just want the cloth to have convincing motion, and I've never seen a rigged solution look better than a cloth sim. Obviously, if its too expensive, i just have to look at some other option, but I'm really hoping I can make the clothes look natural.
  • Mark Dygert
    Options
    Offline / Send Message
    After talking to two of our code monkeys and running some tests in 3dsmax...

    It's not just the file size of the point cache you have to worry about but the ammount of data it has recorded and now has to be streamed in and updated. Point cache files actually compress pretty well so their file size shouldn't be the deciding factor. The more dense the verts the more data needs to be updated, especailly if very vert is moving. Point cache might work on something like a head band tail, or a small portion of a coat or maybe a cape, a dress might be too much.

    Using the point cache is the right idea, but instead of recording the placement of every vert per frame, you record the postion of a handful of bones and the influance they have over surounding verts. Same idea, less intensive, much more friendly to real time.

    I think the part that is hanging you up, is that you're using bone rotation instead of bone position. But that really depends on the engine. It also depends on the style of the dress and the engine you're using as to how you should rig it up. It also depends on what app you're using... I'll try to keep things theoritical and generic.

    Normally you get your cloth sim working great with a pretty high poly piece of cloth. Then place free floating bones around the cloth. The bones aren't linked in a chain but linked to the pelvis. These act as "listeners" and are constrained to follow one vert (or average across a few verts) on the cloth sim object. It depends on the engine as to how many bones you can have. You also need to be mindful of how many bones influance a given vert.

    If the cloth is really important and it covers the legs, you can start hacking out bones, maybe use 1-2 spine bones instead of 3-4, wack out fingers, toes ect... to free up enough bones for your cloth. Make sure you're only applying cloth to moving parts. Think back to Max Payne's coat, only the ends had a cloth like effect the rest of the jacket was ridgid.

    Then there is another copy of your cloth object that is skinned to these bones but does not contain the sim, sometimes much more low poly. This piece is the final output and what people will see in game.

    So bascailly your bones are following and recording the cloth sim and translating it to bone position data. If you're using UE3 there is a setting when you import the character to use free floating bones (I forget what its called, but its a check box).
  • adam crockett
    Options
    Offline / Send Message
    adam crockett polycounter lvl 19
    Nice write up, Vig. Thanks for putting the time in to it. I'm not sure how Im just now getting around to reading it, must've missed the email notification!

    It sounds like a good middle-ground solution, and I'll work it into my tests. Im sidetracked on another project at the moment, but I'm going to switch back over to the cloth thing, probably next week.

    Thanks Again!
  • adam crockett
    Options
    Offline / Send Message
    adam crockett polycounter lvl 19
    found this today. Good visual example of cloth rigging.
    [ame]http://www.youtube.com/watch?v=SGBuw8t6JFg[/ame]
  • Mark Dygert
    Options
    Offline / Send Message
    AVT3467_necromancer.jpg
    lil'bit O' Necromancy going on... but some good info added =)
  • cptincognito
    Options
    Offline / Send Message
    worked out a quick of proof of concept in maya with nCloth and some existing scripts. Currently makes too many joints, but could be pruned down to a lighter cage with a little more work.
  • adam crockett
    Options
    Offline / Send Message
    adam crockett polycounter lvl 19
    Vig wrote: »
    AVT3467_necromancer.jpg
    lil'bit O' Necromancy going on... but some good info added =)

    I figured it was better than starting a new thread... you know.. keep the information in one place. For searches and stuff.
  • adam crockett
    Options
    Offline / Send Message
    adam crockett polycounter lvl 19
    worked out a quick of proof of concept in maya with nCloth and some existing scripts. Currently makes too many joints, but could be pruned down to a lighter cage with a little more work.

    Nice, now make the dress go down to the floor, then wrap it in a long trenchcoat with wizardy sleeves, and you'd be getting close to the designs I'm having to deal with! ; )
  • Mark Dygert
    Options
    Offline / Send Message
    Throw in ankle length hair, tattered wizardly sleeves and a tattered wedding dress and that's what I had to deal with on my last game. Everything was rigged for real time except for the hair and the particles. She had to walk, fly and be viewed up close in some dialog, luckily she only grunted and nodded so we could use a simplified face rig.

    24 bones for just the cloth...
  • cptincognito
    Options
    Offline / Send Message
    Heh, yeah, not sayin it's a complete solution- just thought it'd be fun to see how quick i could get a tutu on an imp :poly142:
  • Rob Galanakis
    Options
    Offline / Send Message
    Nice, now make the dress go down to the floor, then wrap it in a long trenchcoat with wizardy sleeves, and you'd be getting close to the designs I'm having to deal with! ; )

    Yes but do your characters have to ALSO flip and move like Jedi?
Sign In or Register to comment.