r2 - 22 Aug 2007 - 11:00:45 - MattEstelaYou are here: TWiki >  Maya Web > WebLeftBar > MayaAnimation > MayaBatchRenderOptions > MayaCloth

Maya Cloth

Note that this is all for old cloth (called 'classic' cloth in 8.5), not ncloth. The classic cloth plugin is now disabled by default, so it seems you're definitely advised to ignore it, and get on that ncloth gravy train. From some quick experiments it seems ncloth is definitely faster-better-stronger, I'll write some notes for that eventually. I'll leave this all here though for completeness.

-matt

The basic workflow of cloth

The maya tutorials are good, but its not clear how you're meant to start a cloth project from scratch, how to adjust it, and the other little things you'll be likely to do. This tutorial sets up a piece of cloth, then I'll explain what you'd probably end up doing with it in a real world situation.

  1. Create a nurbs square, scale it about the size of the perspective grid, and move it about 10 units up. Select the curves, choose cloth->create panel
  2. Select the panel icon, choose cloth->create garment
  3. Select the panel again, and in the channel box, set the stitcher resolution to be 100
  4. Select the solver in the channel box, set the solver scale to at least 10.
  5. Create a locator, translate it somewhere on the cloth you wish to pick the cloth up from.
  6. Right click on the cloth to get into vertex selection, choose some verts near the locator, shift-click the locator, and from the cloth menu set choose constraints->transform. Note thats the cloth constraints menu, not the animation constraints menu!
  7. Key the translate channels on the locator, scrub forward and animate it moving around a bit.
  8. (sorry to butt in Matt) I usually do a "start Simulation" around here (from the cloth menu) then hit escape when the pre-sim looks settled. It allows the cloth to fall into place before the animation then takes over. For example a cloth would fall in the centre with gravity, yet stay fixed at the 4 transform locators at its corners. Pre-sims don't add to the cache file, can be reset and I never use a "set initial state" as they can't be deleted at all, at least until I'm at Uber-final stage. - Deano (with too much time on his hands). Pray...continue Sir Matt ;P
  9. Set your play options to play every frame, go to frame 0, and hit play. The cloth will solve, saving its animation into a cloth cache, so that once it hits the end of the playback range it should loop quickly.
  10. Next you can experiment with adding collision objects. Create a nurbs sphere, select cloth->create collision object, then simulation->delete cache, rewind your scene, and hit play again.

What to do now?

So now you've got your basic cloth setup, how do you adjust it to the requirements of your shot? There's a few ways you can edit this:

  • The solver scale is probably the most drastic change you can make. The bigger the solver scale, the more weight and flow the cloth will have (as the name implies, it alters how big maya thinks your cloth is). I find solving at 1, 10, 30, 60 will get me in the ballpark, then incrementing +-5 around that figure to get variations until I find one I like. Don't go too far with this, especially if you're simulating large pieces of cloth, or maya won't be able to solve at all.
  • Next is the stitcher. Its a simple relationship; the higher the stitcher value, the more verts your cloth will have. More verts gives maya more to work with in terms of calculating pleats and motion, which of course translates to higher calculation time. Calculation scales exponentially, with higher stitch values. Setting this value depends on how realistic you want the motion to be, balanced against how much time you have for the cloth to solve. You can't farm cloth solves out (its like particles or rigid bodies in that way), so its important to pick a value that'll let you do several iterations comfortably. Deano again: One trick I usually do is to set up about 3-4 mel shelf buttons to change between vert amounts, this allows quick jumps between different res cloths while doing R&D, as well as it will reset the cloth pre-simulation to zero (flat) every time you change stitch values. For example 50, 125, 250, final res. Works for me!
  • Next are the panel properties. These are the basic properties of the cloth (strechiness, weight, thickness). The key values I've found are bend resistance and stretch resistance (self explanitory), density (the weight in grams of the cloth per cm/sq), and if you're colliding with objects, the static friction (how much cloth resists motion once its still) and dynamic friction. Stretch resistance I found important, standard values for me were between 50 up to 1500. Density from 0.001 to 0.1, and static friction down to 0.1 (the cloth sticks too much to surfaces at 0.6, moving in fits and starts as it slides across a surfaces).

Note that the same values in the defaultProperties can have very different behavior depending on the solver scale, stitcher, and the surface area of your cloth. I've got caught when I've got my cloth behaving exactly as I want, then upping the stitcher values, or even just applying the same properties to a larger piece of cloth, and it behaves entirely differently. Makes sense I suppose; a length of silk trimmed into a hankercheif would act differently to the same run of silk used as bedsheets. Still, its not a pleasant discovery after an 8 hour cloth solve...

  • Then would come the objects you're colliding with. We found the hard way that you can't use overly complex geometry. Bevels and seams especially freak out maya cloth, so always make simplified proxies for your solve. Andy Boyd at FSCFC found a quick way was to run a merge verts on your poly model, and gradually slide up the min distance until all your detail areas disappear. Cloth didn't seem too fussed about the way merge verts messes up the geometry slightly, which is a good thing! Then check your collision object offset and depth. The rule of thumb given on another site is the offset should be half the depth or less. I start with offset 0.2 and depth 0.4 and work from there.

So here's a quick rundown of the above process. Taking the tablecloth on sphere example from earlier, I want it to look more like a piece of carpet or thick rug. First thing, its too stretchy, and the stitcher res is too low. So I bump up the U+V stretch resistance to 200, and the stitcher to 200 as well. It now has pleats because the stitcher has given it enough surface detail to do so, but its also meant upping the stretch resistance hasn't had as big an effect as I'd like. Bump it up to 400, try again. Hmm... better, but still too stretchy. Try 800. Nope, going up to 1500. Damnit, this cloth is not respecting my authoritaah! 3000 now. Ah, I've gone too far, it looks like a piece of plastic you'd lay down in a building site. Try 2000 now. Niiice.

But now I realise the movement of the locator towards the end could be better. I go and edit the last 2 keyframes, then scrub back to before the change, and choose 'simulation->truncate cache', then let it resolve from that point. Better still. From this point I might then mess with the solver scale slightly to see if I can get any nice variations, and perhaps the solver oversampling to smooth out some of the faster motion. Finally I realise the camera is gonna be a lot closer than originally planned, so I up the stitcher value to 400, resolve, find all my settings don't work anymore, and start fiddling my stitch settings again... Thats a contrived example, but you should get an idea of the iterative process of cloth. Now onto the bullet points:

Using cloth

  • Creating the initial curves can be a little tricky. You need at least 2 curves that must be co-planar and touching at their ends. One of the easier ways to do this is draw your panels with a single degree 1 curve from a top view, then detach it at each corner. If you need a single circular panel, create a nurbs circle, and detach it into 4 equal sections.
  • For making clothes with cloth, you'd be wise to find dress and shirt patterns and adapt them to your needs. Cloth is designed to work this way, stitching panels together to form a garment works surprisingly well.
  • Make sure your collision objects are adequately tessellated, otherwise the cloth will fall through and cause weird results. Watch for this on poly objects, its easy to create massive n-gons.
  • Pleats take a little bit of work, but not too much. First place to look is the cloth properties; if you lower the bend resistance and stretchiness, the cloth should start to pleat naturally. Next step is to paint in bend angle values with the 'paint cloth properties' tool. Finally you can use tranform constraints, but with 'is soft' turned on. That way its similar to using elastic bands to pull the cloth around, if you use several transform cosntraints and animate them bunching together, you can create nice pleats. A problem occurs if you need to drape your pleats over surfaces; often they'll do what you'd expect and smooth themselves out. What you expect and what you want though are two different things!
  • When you create constraints, their nodes are parented beneath the cloth transform node.
  • If you paint values into your cloth, it works in UV space rather than in vertex space (cloth creates correct uv's as soon as you create a garment). This means you can alter the stitcher values, and your painted values will remain. Handy!
  • Multi-resolution cloth works well. If you have a large sheet of cloth for the overall sim, but need hi-res cloth close to camera, you can stitch panels together, then increase the resolution factor for the indivdual panel properties. So one corner can have a factor of 4, and the rest at 1.
  • Sometimes cloth UVs will corrupt themselves if you change stitch values on multi-panel cloth. If you're lucky, your cloth starts in a completely flat pose, in which case you can duplicate the cloth at the start pose, and run a planar uv project, along y, with 'maintain aspect ratio' checked, which should match your original cloth uv's. You can then run a poly-transfer to get the uv's back onto your original cloth.
  • If your cloth is moving in fits and starts as it slides over a collision object, try lowering the static friction value in the solver. I normally start with 0.1.
  • If its still popping, your cloth res might be too low for the object yoru colliding against. Again, cloth relies heavily on the tessellation for the quality of the sim; think of each poly in your cloth as a piece of hinged tile, like chain-mail. The smaller you get your polys, the more cloth like its gonna look (and the longer your sim will run per frame, but what would you expect?)
  • As you increase the resolution factor, you'll want to lower your stretchiness; the more play the cloth has, the more elastic it'll behave unless you do something about it.
  • Similarly, while it'd be nice to run tests at lo stitch values then simply increase them pre-render, cloth quite often won't behave like you'd expect as you raise the resolution. Its more accurate to run tests on a small piece of cloth at hi-res, then to run test on a large piece of cloth at lo-res. You can't rely on this though, so make sure you have ample time to run several sims of your cloth at its final stitch settings and size.
  • As you increase resolution it takes longer and longer for maya to calculate the first frame of the sim (eg, if the rest of the sim takes 1 minute per frame, the first frame can take 20 mins to start. I've had other sims never get past the first frame!). A way around this is to use 'truncate cache' rather than 'delete cache' as you make changes. Of course this only works for changes that won't make the existing case invalid. Changing cloth res, moving panel curves etc. won't allow you to truncate cache.
  • Try and keep your settings as 'sane' as possible, otherwise cloth will become unstable and give stupid results. Its difficult to give surefire values here, as they change depending on the scale and complexity of your cloth, but within 4 or 5 runs of a simulation you should get an idea of the range of numbers you can use. Stretch resistance is a good one to watch for; if you push it too high the cloth won't have enough play to settle and move correctly, and it'll jitter and shake itself to pieces. Same goes for having it too low, gravity too strong, friction too low/high, bend resistance too low/high, moving constraints too quickly, moving constraints though collision objects etc..
  • You can use ajrTimeWarp to adjust timing of your cloth. It correctly does linear interpolation in the subframe areas, so you can slow cloth right down to get that nice hi-speed silk look. Just remember you'll have to connect the timewarp curve to the solver yourself, ajrTimeWarp doesn't recognise the solvers inTime attribute for some reason. Thanks to Andy Boyd at FSCFC for proving this worked when I was sure it didn't!
  • Another cool discovery of Andy's is you can use deformers on cloth. This didn't even occur to me, I assumed if you changed the stitcher settings, the deformers wouldn't work anymore. And if you use vertex based deformers (ie clusters), thats true. But the rest, lattices, wires, waves etc work great, and continue to work no matter what you do to the cloth. This is a fantastic way to get control over your cloth; if it won't sag in a certain area how you'd like, just lattice it, and you retain all your nice clothy motion. Just watch how you setup your deformers though, make sure you don't stretch it too far or the deformers will become to obvious.
  • Its better to think of cloth as a motion generator like the rigid body solver, rather than a one-stop-shop. People generally run cloth sims on full-size lo-res proxies, then wrap their hi-res geometry onto the cloth. The usual caveats about wraps apply (they use lots of memory and can crash renders if you're not careful), but its a better option than trying to run cloth sims on your hero geometry.

What doesn't work in cloth

These are all warning notes if you plan to use maya cloth as the backbone of a job (like closeup shots of maya cloth draping over an object). In short, don't. Cloth works great for mid and background shots, or for anything where its not the center of attention. For hero animation, it's a lot of hassle, here's why:

  • Its difficult to swap out to a keyframe based method when things get rough. And things will get rough.
  • Simulation times scale up exponentially as you increase stitch values. Invariably, if you're doing a closeup, you'll push the stitcher higher and higher, then find the stitch value you need can't be solved. Once you hit that point, its time to start looking at whatever deformers you can use to fake it through other means. Wires and lattices are your friends!
  • Never never never never use hi-res, hero geometry as collision objects. Bevels, detail, badges, logos etc... will all catch and snag on your cloth, causing all kinds of grief.
  • Cloth can sometimes be inconsistent. I've done solves where the last 5 frames suddenly freak out, truncate those last frames and resimulate, and it solves perfectly. This means quite often your solves are just down to luck, which is never a good thing to rely on!
  • Cloth renders horribly in closeups. The irregular tesselation that assists in the simulation looks ugly as hell if you have to render it. Polysmooths help a little, but the most correct option is to wrap a clean nurbs or poly object to your cloth. Unfortunately, its extremely difficult to get a hi-res surface to wrap correctly to hi-res cloth, usually it'll just crash maya.
  • If you could use bakeCloth on all sims, it wouldn't be so bad, but if you're using hi-res cloth, you'll hit memory limits on blendshapes well before the end of your sim, causing more problems. We were lucky enough to have an in-house tool that can cache out vertex animation to external files, I have no idea how we would've finshed our project without it.

Using cloth for ropes and cables

A few quick things to watch for, many many thanks to Andy Walker at Framestore-CFC for some helpful hints.

The basic theory is you create a long thin strip of cloth, like a ribbon or piece of tape, sim that until you get what you need, then wrap a curve to the cloth, then loft a circle down the curve. Compared to the other standard method of using springs on softbodies, or god forbid, chains of rigid bodies, cloth is faster to solve, faster to setup, easier to edit, easier to control, and the results look much, much better. Here's the quick workflow:

  1. Create your nurbs square
  2. Scale it so its long and thin (not too thin though), I used a scale of sx=38, sy=38, sz=0.5
  3. Select your square, cloth->create garment (handy little shortcut)
  4. Set the stitcher res to 100, solver scale to 10
  5. Create 2 locators, translate them to each end of the cloth, then select the corresponding cloth verts and locators and chose constraint->transform.
  6. Animate the locators doing whatever, and simulate the cloth. Hey presto, instant rope animation.
  7. At frame 1, create a nurbs curve with maybe 100 cv's that runs down the length of the cloth. Wrap it to the cloth, then loft a circle down the curve. Done!

  • Maya 6.5 added the new hair system, giving nice fast rope/cable/hair simulation. In doesn't look quite as physically correct as using cloth (the motion is akin to a fancy realtime game simulation to my eyes), but it should be good enough for most projects, and much easier than setting up cloth.
  • If you can get by without cloth inter-collisions, turn it off in the solver attribute editor, makes things run much faster. Same goes for any of the friction attributes, turn down/off anything you don't need.
  • Don't make cloth too narrow in one direction; if you're having to push your stitcher res above 2000 to get the right looking tesselation, make your cloth bigger and/or wider.
  • When using collision objects, the default offset of 1 is usually too large. Bring it down to 0.2 or thereabouts (this is the distance in cm apparently before cloth starts colliding).
  • For rope I found that setting solver scale to 2 or 3 got better looking results, even if you're already working at a large size.
  • In general, solver scale is a quick way to cheat weight and flow; a cloth square roughly the size of the persp.grid moves like a tissue at a scale of 1 (fairly rigid), like a bedsheet of satin/silk at a scale of 5, and like a circus tent at scale 20.
  • Once you're done, find the bakeCloth script on highend3d to convert your sim into a blendshape, very handy! Don't forget you can use bakeCloth on any shape, so you can bake the wrapped curve into a blendshape too.
  • Keep an eye on your 'break even' point when using cloth to do rope; If you're doing fast, specific motion, a combination of deformers (sines,clusters,lattices etc) can be the better option, and especially if your rope needs to be directable and editable.
  • If your rope can be broken down into sequences of motion("shoot out of a harpoon gun, then stick in a wall and become taut"), use blendshapes on curves to ease the workload. Do the first half using deformers on one curve, the second using a curve wrapped to cloth, then use a third curve which blendshapes from one to the other.

Cloth for other things

I was chatting with a friend about doing crash simulations, had a hunch you could use cloth for this.

Started with a simple car model, ran a few merge verts to delete any fine edges, converted it to a cloth object. Set the solver scale to around 10, set the stiffness higher (around 4000), then animated a cylinder hitting the bonnet. Looks like nice slow motion footage of car crash tests. Here's an example scene for maya 4.5 or higher: carCrash.mb

Other resources

Thanks aplenty to everyone at FSCFC commercials for helping with this, specifically Jake Mengers, Andy Boyd, and Chris Syborn.

-- MattEstela? - 18 Feb 2004

Topic attachments
I Attachment Action Size Date Who Comment
elsemb carCrash.mb manage 315.5 K 09 Apr 2007 - 18:18 MattEstela car crash example using maya cloth
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback