+$Set in medieval Scotland, Pixar’s latest feature film is a testament to the ability of Pixar’s scientists and artists to create a tactile world.
+$Brave’s landscape is lush, lead character Merida’s long mop of curly hair is as wild as she is, and all the characters wear costumes with more layers and detail than in any previous film. Simulation is a star of the film, too.
+$Claudia Chung, who began her career at Pixar as an intern in 2001, was simulation supervisor on Brave. Chung attended the University of California in Berkeley and interned at Johns Hopkins Applied Physics Lab in Maryland, then started work as a rendering artist and technical director on Finding Nemo.
+$She added the role of simulation artist on Ratatouille and technical director on The Incredibles. For Up, she was the cloth lead.
+$“The challenge of this film was the sheer complexity and artistry,” says Chung. “Fergus had eight layers of cloth draped together in his kilt. And Merida... when we looked at the story reel three years ago, we counted the number of times she changed costumes. And then we said, ‘Oh, she just ripped her dress. And, oh, she ripped it again.’”
+$For Merida’s debut, her mother laced the free-spirited girl into a corset and dressed her in an extremely tight dress. When Merida later decides to show off her archery skills, she rips the dress to give herself some elbow room.
+$The first film at Pixar with a character wearing a costume that required cloth simulation was the short animation ‘Geri’s Game’, which won an Oscar in 1998. To move Geri’s costume, Pixar’s senior scientist Michael Kass created a cloth solver. When senior scientists Andrew Witkin and David Baraff joined Pixar, the three members of Pixar’s Research Group built a new simulation engine, which they named FizT.
+$“We started over from scratch, using the knowledge all three of us had to do the simulation,” Baraff says.
+$The simulator and system they built handled the hair and cloth dynamics for the characters in the Oscar-nominated film Monsters, Inc, including Sully’s fur and Boo’s t-shirt. With some evolutionary updates and one exception, Pixar has used FizT for cloth and hair on every film since.
+$The exception is Brave, which uses a completely new hair engine, Taz, developed by Witkin to handle Merida’s long tangle of curly hair. However, FizT will be driving hair and cloth sims again for characters in the upcoming Monsters University.
+$Until the Pixar team developed FizT, cloth simulation systems typically used history to determine whether cloth regions interpenetrated.
+$In those systems, any errors along the way often resulted in tangled cloth. The new methods the Pixar scientists devised to untangle the intersection problem resulted in a Siggraph 2003 paper and a patent. All three scientists received a Scientific & Engineering Award in 2006 for developing the cloth system.
+$“The system literally finds and traces all the intersections, and finds regions of the cloth surface,” Baraff says. “Then, it determines that this region has gone through that region. Usually you keep cloth apart with the springs between. The system understands, though, that pushing apart is not always right. Sometimes a region of cloth needs to push in reverse. Our system does a geometric analysis of the intersection; it traces all the lines to understand what it means.”
+$He offers a way to think of this mathematical process visually: “Imagine that you have two pieces of flat cloth floating in space an inch apart. Now, throw a ball on the top piece of cloth and push down until it goes through the bottom cloth. If you look at the line of that intersection, you’ll see that it’s a circle. That’s the circle of intersection. Both pieces of cloth have this symmetric region inside the circle. And inside the circle, all the points have gone through the other cloth. The cloth points inside the region want to attract their buddies, pull back through, and get out. Outside the region, the cloth wants to push apart.”
+$The algorithm that the team developed to trace and analyse all the intersections, determine the regions, and decide what to do is extremely complex. “It’s by far one of the most complex algorithms we’ve ever written, and I’m a fan of simplicity in programming,” Baraff says.
+$“Only in dire circumstances do we do something this complex. But it is the best we can think of. And as long as it keeps working, we keep our hands off that piece of code. I hope to never again have to write an algorithm for as geometrically complex a problem as this.
+$“I described the simplest case. As soon as you do the simulation for real, you end up with harder cases. So, there’s one more state. If you have a small piece of cloth that is confused and doesn’t know what to do, it won’t do anything. If it goes down the code path and knows it’s confused, it won’t attract or repel. It doesn’t do anything that might make the problem worse,” he adds.
+$Feeding The Beast
+$Despite the complexity, the FizT simulation engine is much smaller than the software surrounding it, and has changed less. “You could think of FizT as a nuclear reactor in a small building,” Baraff says.
+$“But it’s fed by 200 million miles of pipe. The things that feed it dwarf the simulation.”
+$For The Incredibles, the crew focused on the modelling pipeline. “For Monsters, we needed to get something that worked,” Baraff says. “It took us six months to create one lousy t-shirt. For The Incredibles, it was, oh my gosh, we have a tonne of characters and more than one hundred times the number of garments. We got through it, but the simulator didn’t work as well as we wanted.”
+$One problem was what they called ‘oozing.’ The system had an inertial field generator (IFG), that could examine a character’s motion and impart a compensating force. When Mr Incredible flies off at high speed, for example, the system would effectively tone down the motion and base the cloth dynamics on only a fraction of the forces. But when the character stopped, it took too long for the cloth to settle in place.
+$“We fixed it manually for The Incredibles,” Baraff says. “Then for Ratatouille, we focused on simulator improvements, and got nice anti-oozing. The clothing locked onto the characters in more controllable ways.” Anti-oozing can happen automatically, or animators can keyframe the movement for more subtlety.
+$Modellers had tailored the clothes for the characters in Monsters, Inc from 2D patterns as if they were sewing clothes by hand, and continued doing so for all the subsequent films. In fact, when simulation artist Emron Grover started as an intern on Up, Pixar enrolled him in a real-world sewing class.
+$Baraff explains why 2D patterns were important: “With 2D models, because all the shapes are flat in the plane, you get a perfect UV coordinate system. This is important because real cloth is made from flat pieces – everything can be flattened. But, when you model in 3D, it’s possible you’ll make things like a sphere that can’t flatten.”
+$“Everyone knows this is hard,” says Baraff. “Even if you can flatten a 3D model, it almost always requires human intervention to make it perfect. Sometimes you have to make cuts to lay out the UV coordinates. And in the case of cloth, if you get distortions, it doesn’t look right. So with the 2D patterns, we had flat panels. The system generated a dense mesh on the fly. And we had a perfect UV coordinate system on the mesh.”
+$However, finding and training people who understood how to create the 2D patterns became untenable; the skill set was too specialised. This problem came to a head with Brave. “The stumbling block was finding a way to get this pristine coordinate system in 3D,” Baraff says.
+$“When we realised that we had overstated the problem by saying we needed a perfect UV texture system, all of a sudden it became easier to do. We needed something close, but not exactly the same. The new system, called 3D Cloth or C3D, has been the major cloth simulation evolution over the past couple of years. We tested it on Toy Story 3, because we had the luxury of trying it but not having to rely on it. We knew we’d need it for Brave.”
+$Modellers working on Brave would need to create 22 costumes for Merida, put nine or ten simulated garments on Fergus at the same time, fashion three dresses for Elinor, create full kilts for the triplets, the three lords and their sons, and build 29 modular garments for tertiary characters that would produce 94 unique costumes. The C3D system helped make that possible.
+$As well as opening up the costume department to 3D modellers, C3D produced benefits throughout the pipeline. Before, because the system generated the mesh on the fly, every time the shape changed, it generated a new mesh.
+$So when a garment created with 2D patterns changed, the shading had to change too.
+$“People tried to shade as late as possible because they were afraid the garment would change,” Baraff says. “C3D allowed us to break that chain. It’s easier to make changes to the shading as things go along. Modellers create the lowest-resolution mesh they can, and we automatically up-res for simulation. The shaders shade on that nice, low-resolution mesh, and their data transfers to the higher resolution mesh that can bend, deform, and wrinkle.”
+$Modellers using C3D create garments with quad polygons, using edge loops to tell the tessellator where there are seams, darts, and gathers. “The system tessellates the model into a triangular mesh, and that’s what we simulate,” Grover says. “The modellers build the clothes on the characters’ bodies, which means they can tailor the proper fit. Once they tessellate the model, the simulation artists run FizT to relax the cloth and see how it looks.
+$“In the beginning, we tailored Merida’s dress both ways to see which was faster, and which looked best,” Grover says. “After the first pass on Merida, we found that the 3D held up if we did it right, and it was a little faster.” And, for the most part, the Brave crew stayed with the 3D models, although in a few cases, the simulation artists devised a hybrid 2D/3D approach.
+$“It’s funny,” Baraff says. “For ‘Geri’s Game’, which had the first cloth simulation at Pixar, before Andy Witkin and I got there, they modelled Geri’s jacket in 3D. Andy and I said there was a better way; there was something key in 2D that gave us the specific look of cloth. Everyone said, ‘What? You’re going to model clothes in 2D?’ But, in 2007-08, when we knew Brave was on the horizon and that the costumes would be complex, we changed the way we built our cloth garments. And, people said, ‘What? You’re going to model in 3D?’ Few people remembered that we had done this in 3D many years ago.”