Search Unity

Realtime physics vs pre-baked physics in clothing

Discussion in 'General Discussion' started by Seyren, Feb 4, 2016.

?

What do you prefer for animating clothes in general?

  1. Pre-baked

    10 vote(s)
    47.6%
  2. Realtime

    11 vote(s)
    52.4%
  1. Seyren

    Seyren

    Joined:
    Feb 26, 2014
    Posts:
    14
    I'm not sure if this is the proper word, but i wanted to ask the following:

    When you have to create physics, would you rather use rigidbodies from unity, or do an animation, for example, in 3DS Max?

    I'm no sure about this 100%, but i would believe that a pre-baked animation would improve the perfomance, but i guess it would remove some realism of having realtime physics, but if for example, you want a skirt to move with bones and use it in a character, what would you choose?

    This would mean you have to animate every single animation that the character does along the skirt, but i guess is not that annoying when it's calculated with the program's physics automatically with each animation you do.

    I was wondering what would people use, because i think that Unity's physics can screw up a cape or a skirt if not done properly.

    What would you choose?
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Preference has nothing to do with it for us. It's about if it meets performance targets.
     
  3. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    Nope. Both have to do with it. Some people prefer look of pre-baked stuff, some like realtime more, but if either isn't performant enough you try the other.

    Anyway, I prefer realtime mainly because when clothes fall through player character or nearby objects, it's a real immersion breaker for me.
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm pretty sure I know my own case, and I did talk about our case. We choose to use it based on performance targets.
     
  5. darkhog

    darkhog

    Joined:
    Dec 4, 2012
    Posts:
    2,218
    You!=all gamedev industry. And yes, I'm still angry at you.
     
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You can be as annoyed as you like my sweet little hoggy. I still love you.
     
  7. McMayhem

    McMayhem

    Joined:
    Aug 24, 2011
    Posts:
    443
    There's a pretty solid question here, and it's one I've been pondering recently as we're starting to get in some armored trench-coat models and the dangling fabric needs to be solved for. Currently, the way I've been doing it is using a tail bone on the character. A separate rig for trench armors or anything where cloth hangs from the body. This works for me because my game's perspective is isometric-esque and the models are fairly low-poly. Not sure if that solution would do well for others.

    I know DirectX11 offers some pretty fun options when it comes to cloth simulation. Unity's native cloth physics (although the last time I tried it was with Unity 3.5) are not so good on performance, even with low-poly skinned meshes.

    Other than bones, there is another way to animate cloth. You can write a shader that incorporates vertex displacement and have it use a variable you pass in through your code. Of course that means you'd potentially have to hand set all those parameters for each animation, which would be a huge pain.

    Either way, I'm curious to see what someone whose actually implemented a solution for this has to say. I'm hoping there's a better way than my current hack-bone method. :/
     
    Seyren likes this.
  8. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,156
    Now kiss.
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I would but my lovable green dragon is elusive and still angry no doubt.

    It's way better now. You just model normally, then using cloth component, paint the bits that flap in the viewport. Give it a try. It's still better (for unity and AAA devs) to rig the occasional longer piece of cloth though, simply because it has the right behaviour. But for coat tails, and general clothyness, you only need skinnedmeshrenderer + cloth component, no need for separate cloth.
     
    theANMATOR2b and McMayhem like this.
  10. McMayhem

    McMayhem

    Joined:
    Aug 24, 2011
    Posts:
    443
    That's incredibly helpful. Thank you for that. I'll have to give the docs on that another look to see what kind of options there are for solving by distance, but otherwise that would be a fantastic solution to a real problem I've been chewing on.
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It even internally supports fading the cloth to a non sim so you can ease to lods easily or remove the performance hit without a visual glitch.
     
    theANMATOR2b likes this.
  12. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,052
    Pretty much this. It all depends on the needs of the game and resources available. Animation gives you more control and much more performant. Downside is that if you don't do enough animation, it looks canned. But mix it with some subtle shader effects and you do pretty good.

    That said, Thor sucks.
     
  13. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    YOu won't be able to use full realtime clothing physics in video games, period. Even the best cloth sim solution I saw - Marvelous Designer - is quite slow and is prone to exploding when you start layering cloth.

    You can physically control some hanging cloth on your character, but for the best quality you'll need small number of characters and that is going to need a lot of fine tuning. That kind of thing is often used in 3d fighting games (when there are only two characters, using dynamic cloth is easier).

    Regarding pre-baked clothing. You'll definitely want that in your cutscenes, but if your character has dynamic animation of any kind, that is not gonna fly.

    In the end you'll need some sort of compromise between all methods. Some limited clothing animation driven by the bones, some limited animation driven by physics engine, and maybe some vertex animation in some cases.

    When I was playing GTA I've noticed that they do interesting trick there and blend several normalmaps on clothing in order to simulate wrinkles that appear when character body twists. That kind of stuff too.

    By the way, Unity cloth system is not very good and clothing can only collide with bunch of predefined volumes/ planes you directly specified in the component, but won't dynamically interact with the world. That's something worth keeping in mind.
     
    nirvanajie, McMayhem and Seyren like this.
  14. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    I've been prototyping cloth setups for a while - only considering desired look/feel without consideration for performance.
    Here are a couple interesting links that I've found useful.
    Cloth bones exported to be used with real-time physics in engine - not cloth. http://farfarer.com/blog/2011/07/07/unity-skeletal-ragdoll-jiggle-bones-tutorial/
    Alternate cloth system. https://www.assetstore.unity3d.com/en/#!/content/40758
    http://forum.unity3d.com/threads/obi-cloth-bringing-old-cloth-back-to-unity-5.337322/
     
    Seyren likes this.