Sie sind auf Seite 1von 4

TUTORIALS | Cloth simulation

MAYA

Sackcloth and gashes


Creating realistic animated cloth is a notoriously difcult process, but this tailor-made tutorial BY KIARAN RITCHIE should help you get even the most misshapen characters clad with ease

T
FACTFILE
FOR Maya Unlimited 7+ DIFFICULTY Intermediate TIME TAKEN 10-30 minutes ON THE CD Full-size screenshots Maya scene les Character turntable movie Playblast movies ALSO REQUIRED N/A

here are a handful of visual phenomena that are devilishly difcult to simulate with a computer. Fluids, hair, fur and cloth are notorious for requiring complex and expensive software,

for a weakness. The truth is that Maya Cloth can be hard to learn, but its difculty is proportional to its exibility. I want to mention that many people prefer the SyFlex plug-in for serious cloth work. In my experience, SyFlex has denitely been somewhat easier to work with and perhaps less prone to instability. The SyFlex solver seems to adaptively adjust itself where Maya Cloth requires a little babysitting from time to time. The bottom line: if you have the money, get SyFlex. However, Maya Cloth is still a capable solver. This tutorial will provide an overview of a production-worthy workow for creating believable cloth animation. Well follow the creation of a cloth garment for the Minx character from the upcoming The Art of Rigging Vol iii. In the textbook, youll nd every detail of this fascinating topic, including the creation of our characters hair/fur, cloth and much more. Kiaran Ritchie is an author on The Art of Rigging series from CG Toolkit. Hes currently working on a number of PS3 projects at Factor 5 in San Rafael, California www.cgtoolkit.com

talented artistry and powerful computing. But these effects, while feared by digital artists, are able to lend a sense of realism to CG work not easily achieved by any other means. While the topic of this tutorial is cloth, all of these effects share a common trait: extreme complexity. You dont have to look any further than your own shirt to witness the breadth of chaos exhibited by a simple piece of cloth. The cascading folds of material on a typical T-shirt would be enough to send any polygon modeller screaming for help. Fortunately, help isnt far away. This tutorial is meant to introduce you to a typical workow for animating cloth with Maya Cloth. This is a powerful toolset which, in my opinion, deserves some serious attention. Its not the easiest thing in the world to use, but its reliable. Novice users are often confused by its somewhat odd workow, mistaking its steep learning curve

066 | 3D WORLD June 2006

TDW78.t_cloth 066

7/4/06 1:50:35 pm

Cloth simulation | TUTORIALS

STAGE ONE | Drawing the panels

Open stage01.mb from the CD. This scene le contains the Minx character. Unlike most cloth software, Maya Cloth provides a method of both animating and modelling clothing. This is an often misunderstood feature that, when used correctly, can create excellently constructed garments with ease, using a realworld pattern/panel/sewing paradigm.

01

To model a garment with Maya Cloth, we must start with a pattern. This pattern represents the various pieces of cloth (panels) that will eventually be sewn together to form the nished garment. A panel is constructed from three or more planar NURBS curves that form a closed loop. A typical garment may comprise several panels that are sewn together to create a polygonal mesh.

02

Creating garment patterns is beyond the scope of this tutorial, but you shouldnt have to look further than your local fabric store for numerous examples of various patterns for common garments. For the Minxs robe, I constructed the panels without a set pattern, but for a more humanoid character, it would be easier to use a premade pattern. The Minxs robe uses 18 separate panels.

03

EXPERT TIP
Streamlined sewing

To draw a panel, select the EP Curve Tool and trace the pattern. Create a new curve for each segment of the pattern. Use the [c] key to snap the start CV of each new curve to the end CV of the last curve. Make sure you create the curves in an orthographic viewport in order to keep them planar. The size of a panel determines the surface area of the resulting cloth.

04

You can now group the panel curves and position them around the character. This stage usually involves lots of trial and error. The panels must be sized to give the garment enough cloth so that it drapes properly. You may nd yourself returning to this step several times to ne-tune the t of the clothing. Remember, a larger panel creates more cloth, which results in baggier clothing.

05

The process of creating panels, sewing them together, draping, tting, adjusting and resizing can be quite time consuming. To streamline the process, we can create an instanced duplicate of the cloth curves to use for resizing, while the sewn garment updates in real time. To do this, create an instanced duplicate of the panel curves before turning them into panels. You now need to create the garment from the duplicates and sew it together. From here, you can simply adjust the shape of the panel curves to quickly tailor the garment.

STAGE TWO | Creating the garment

Now open stage02.mb. This contains the nished panel curves, ready to be sewn together into a garment. This process involves three steps: rst, we must turn each set of panel curves into a panel. Second, we create a garment from one of the panels. Finally, we sew the neighbouring panels together, automatically creating the rest of the garment as each new panel is sewn together.

06

Start by selecting each set of panel curves from the Hypergraph. With a complete panel selected, choose Cloth > Create Panel. This will create a shirt icon in the middle of the panel. Go through the Hypergraph and make a panel for each group of curves. Now were ready to create the garment. Select a panel icon (the shirt) and choose Cloth > Create Garment. This creates a polygon mesh.

07

Now lets begin sewing everything together. Start with the panel that was turned into a garment and sew it to all of the neighbouring panels. To do this, select two panel curves and execute Cloth > Create Seam. This will add the new panel to the garment and extend the polygon mesh into the new panel. Work your way through the rest of the garment, sewing all the seams together.

08

June 2006 3D WORLD | 067

TDW78.t_cloth 067

7/4/06 1:50:38 pm

TUTORIALS | Cloth simulation

STAGE THREE | Adjusting the Cloth solver and adding collisions

Open stage03.mb to see the fully sewn garment. Now select the garment and nd the cpStitcher1 node in the Channel Box. Set the Base Resolution attribute to a value of 600. This will create more polygons for the solver to use when creating folds and collisions. Higher resolutions yield more realistic folding, but at the cost of longer simulation times.

09

Because Maya Cloth uses a pseudo physically based simulation engine, the scale of the solver must be set in order to produce realistic results. This is computed by taking the real-world size of the garment (80cm) and dividing it by the scene size (8cm). Set the Solver Scale attribute on the cpSolver node to a value of 10 (80/8). Leave the rest of the solver attributes at their default values.

10

For a more accurate simulation (especially with collisions), increment the Frame Samples attribute until any interpenetrations or glitches are remedied. The Relax Frame Length attribute is used to drape the garment onto the character. It applies a rubbery material to the cloth to help it pull together smoothly. Set this to 0 after draping the garment.

11

Open stage04.mb. Play back the scene (use Play Every Frame) to run the simulation. At this point, the garment crumples into a ball during the relaxation phase (rst ve frames) and then falls due to gravity. We want it to hang from the character. To do this, select the Minxs mesh and choose Cloth > Create Collision Object. Set the Collision Depth and Collision Offset to a value of 0.1.

12

Run the simulation again and youll notice that the garment now collides with the characters skin. Unfortunately, it gets stuck on the spikes. We want the collision to ignore the faces on the spikes. To do this, select all of the faces (use the Quick Select Set) and choose Cloth > Collision Cloth Set > Create. Uncheck Enable Rigid Collisions on the Cloth Set in the Attribute Editor.

13

Run the simulation and you should now notice that the garment passes right through the spikes. Well cut holes in the garment, but for now we just want the solver to ignore the spikes. Collision sets are useful for cheating the solver and can help you prevent glitches and pinches in the cloth. This concludes the set-up of the cloth, so lets take a look at simulation.

14

STAGE FOUR | Simulating the cloth

Open stage05.mb. Having seen how to create and drape a garment, lets apply these principles to an animation. This scene le contains a more rened version of the garment thats draped onto the Minx. This time, the character has been animated and so we need to set up the simulation so that the cloth ops around as the Minx jumps up and down.

15

Note that the scene le doesnt contain any curves, panels or seams. This garment was created using the same method described earlier, except that, after draping, I duplicated the mesh to create the cloth object. Theres no need to keep the construction history (panels) for the cloth garment after its draped. Also note that holes have been cut into the mesh at the base of the spikes.

16

Now we need to set up the cloth again. Select the garment mesh and choose Cloth > Create Cloth Object. On the solver node, set the Start Time to -10 and the Solver Scale to 10. Because the garment is already draped, set the Relax Frame Length to 0. Make the Minxs mesh a collision object and set the Collision Offset and Collision Depth to 0.1.

17

068 | 3D WORLD June 2006

TDW78.t_cloth 068

7/4/06 1:50:42 pm

Cloth simulation | TUTORIALS

STAGE FOUR (Continued) | Simulating the cloth

Now play the scene. You should notice that the cloth begins to crumple and misbehave around frames 3-5. This is when the Minx springs upwards at the base of the jump. During extremely fast motion, its not uncommon to have to tweak the solver to help it solve. Increase the Frame Samples from 1 to 5.

18

Rewind the scene and choose Simulation > Delete Cache. Each time the simulation is run, Maya saves a cloth cache le (MCC). Subsequent playback will read the cloth vertex positions from this cache data. In order to resimulate the cloth, you must rst delete the old cache. If no cache is found for the current frame, the solver will automatically recalculate it.

19

With the cache deleted, replay the simulation. A modest workstation may take several minutes to compute the 50-frame cloth animation. When the simulation is nished, you can scrub through the timeline to view the animation stored in the cache le. If the cloth encounters a problem, you can truncate the cache from the problem frame, adjust some parameters and resimulate.

20

STAGE FIVE | The nishing touches

You may notice that the cloth doesnt have any thickness. Actually, it lacks any detail that would be superuous to its motion. Unhide the render cloth layer to see a thickened version of the cloth. This copy has been extruded and quadrangulated (for better smoothing), and it will be wrap-deformed to the simulation garment, so that it deforms along with that garment.

21

Select the thick cloth, [Shift]-select the simulation cloth and choose Deform > Create Wrap. Set the Max Distance to 0.2 and Inuence Type to Points. Now the thick cloth is animated along with the simulation cloth. The render garment can contain any extra details and should be smoothed before being rendered. Also make sure to lay out the UVs of the render garment before wrap-deforming it.

22

Its rare that a cloth simulation will be perfect the rst time. This usually requires quite a bit of trial and error, various adjustments and elbow grease. Even if the simulation goes well, there are usually small imperfections, popping vertices or interpenetrations. Its not always easy (or even possible) to x these by adjusting the simulation. Sometimes you need to just dig in and manually

23

model the xes. To do this, scrub to the offending frame and model the correction. When youre happy with how it looks, select the mesh and choose Simulation > Update Cloth State. The cache le will be updated to include the new changes. This kind of cheating is referred to as shot sculpting. Once the animation is looking good, simply hide the simulation garment, smooth the render garment and youre ready.

June 2006 3D WORLD | 069

TDW78.t_cloth 069

7/4/06 1:50:45 pm