[In this Intel-sponsored feature, part of the Visual Computing microsite, Intel senior software engineer Brad Werth explains how multicore CPUs can be leveraged for an efficient method of representing soft-body characters by way of cloth simulation.]
Soft-body physics is an increasingly popular feature in videogames. Due to their computational intensity, soft-body physics are presently used sparingly to depict the movement of cloth, hair, and other flexible elements. This article shows how, with the additional processing power of a multi-core CPU, entire soft-body characters can be created using cloth simulation techniques.
This article draws heavily from a tech demo called Pet Me. The source to the Pet Me demo is available at http://www.intelsoftwaregraphics.com/?lid=2092&siteid=12. There is also a presentation based on this material hosted by Intel at http://software.intel.com/file/6712, and an explanatory video by the author at http://software.intel.com/en-us/videos/gdc-session-pamper-your-pets-with-cpu-power.
Most character animation is done today with a bones-and-skin method. This is sometimes called "skinning" a character. The basic idea is that the motion of the figure is controlled by a small number of invisible control points, linked together as bones. The visible portions of the character are then bound to specific bones. There is some cleanup work done to make joints look correct, or to blend between canned animations, etc. This method has been a favorite for a number of years, because it was a relatively fast way to animate characters given the constraint of a CPU with little computational power to spare. That constraint is rapidly becoming irrelevant with the advent of two-core and four-core processors. With the constraint removed, more sophisticated character animation techniques are possible.
With additional processing power, the bones-and-skin method can be extended for more detailed animation. More bones can be added for additional degrees of freedom. But there is no need to create additional bones unless a new joint is being modeled. Improvements are also possible by focusing on more complicated movement of the bones. Instead of just blending between canned animations, animations can be blended with physics to create dynamic motion in the bones. This is already implemented in games that use "rag doll" corpses, and has been implemented in some middleware products also.
Bones-and-skin is one method for character animation, but it is not the only viable choice assuming that increased computational power is available. Since the skin is the only visible part of the character, an alternative is to ignore bones and calculate the shape and movement of the skin directly. If the skin is disengaged from bones, then only local forces and constraints maintain the character's form. The resulting skin can be manipulated equally well from internal and external forces. A character built this way is sometimes called a "soft-body" character.
In a soft-body character, simulated cloth can be used as a skin. Forces applied to the cloth create the form of the soft-body character. Sock puppets are a simple example of this technique. The cloth provides local constraints to maintain the form of the sock, and the hand provides the forces to give the character volume. When simulating cloth computationally, the hand becomes an invisible mathematical construct and the sock is attached to that construct at key points. By expanding on this concept, a variety of soft-body characters can be created.
Figure 1: Using springs to model cloth
Cloth simulation is a well-known problem in computing. Figure 1 shows how cloth is commonly modeled as distinct points ("nodes") joined by springs. The physical definition of the spring force is calculated from the resting length of the spring, the stretched (or compressed) length of the spring, and a tension constant that defines how strong the spring is. As the equation shows, the force is proportional to the tension constant multiplied by the difference between the current length and the resting length. By arranging groups of nodes and springs, a coherent mesh is created - a cloth.
Figure 2: Cloth draped over a sphere
Here's the classic cloth demonstration showing a flat piece of cloth falling over an invisible sphere. These images were taken partway through the fall. In the wireframe image, the stretching of the center portion of the cloth is clearly visible. Cloth can be draped over any type of shape; the sphere is used here because of its mathematical simplicity.
Figure 3: A ghost created by a classic cloth draped over a sphere
Even something as simple as a draped cloth can start to make an interesting character animation. Figure 3 shows a ghost created by draping a cloth over a sphere. The cloth drapes and flows around this sphere in a satisfying way. When moving, it looks something like a ghost. This is just a start, but it's encouraging that even the basics are already showing some promise.