Thursday, January 26, 2012

Twist and shout: fixing twisted deformation

In "A Joint Effort" (Artist's View, February 2004), we introduced the fix-up bones as a means of combating the regrettable state of conventional real-time skin deformation. Fix-ups work by reproducing a fraction of the rotations in an animating skeleton. Assigning vertices to the fix-up bones, rather than directly to the animation skeleton, prevents the worst forms of vertex collapse around problematic joints like shoulders. This month we're going to look at some advanced fix-up strategies for a different class of deformation problems.

Sick and Twisted

The shoulder is clearly the worst villain of skin deformations, but there are many runners-up with different kinds of deformation failures. The most notable contenders are twisting joints. Necks, forearms, and biceps can all shrink or even turn inside out when twisting around their long axes. The problem stems from the same source we discussed in February. As with ball-joints, the skinning algorithm interpolates vertices linearly between their original and newly rotated positions. Naturally the rotation of the vertices takes place along an arc. The interpolation, being linear, always cuts a chord on that arc, slicing deeper into the volume of the model as the twist increases. At 180 degrees the chord passes right through the origin of the arc--in other words, the bone--collapsing all of the vertices down to a point (Figure 1).


The cure for this nasty hourglass effect is to adapt the strategy we used for the ball-joint fix-ups described in the February column. Twist fix-ups rotate around the long axis of a twisting bone by some fraction of the real rotation. They carry their assigned vertices to positions that reflect the correct rotational interpolation. This preserves the volume of the geometry and prevents the hourglass effect.

Doin' the Twist

Unlike ball-joint fix-ups, twist fix-ups only work in a single axis. This means they have to be controlled by expressions rather than constraints. So before we can build twist fix-ups, we need some way of representing the twist as a number that can be fed into an expression. Unfortunately, twisting (like obscenity) is easy to recognize but hard to define. Consider the arm of a typical animation skeleton. Intuitively we know that the twist of the arm is the rotation around the axis between the shoulder and the elbow. Naturally you'd assume that the Eulerangle rotation value for the axis that points along the biceps would be the twist value. The reality, alas, is a bit more complex. Figure 2 shows three sets of F-curves, which produce identical animations. The only difference among them is the order in which the Euler rotations are executed. As you can see, different rotation orders produce remarkably different results.

[FIGURE 1 OMITTED]

How can you get a good twist value then? The source of the problem is that each rotation influences the meaning of the numbers that come after it. Since each rotation changes the meaning of the next, only the first term in an Euler sequence has a stable meaning. Therefore, it's possible to determine the twist of a bone with Euler angles only if the twist axis is the first axis in the rotation order. Before trying to build twist fixups, double check the rotation order on your bones to be sure the axis which points down the bone is the first Euler term (Figure 3). In both Max and Maya the skeleton tools usually create bones this way by default, with the x as the twist axis and the rotation order set to the conventional x-y-z. But be sure to check! Your defaults may have changed, and building skeletons out of disjointed parts can cause unpleasant surprises.

The bad news about deriving twist values from Euler angles is Max's animation-controller architecture makes it impossible to get consistent Euler values from bones driven by IK, constraints, or TCB rotations. For IK-driven bones, the twist angle value on the IK handle is often an adequate substitute and can be fed to twist expressions. Generally, though, the only alternative for Max users is to create a custom twist attribute and animate it by hand. Ferreting information out of Max controllers for expression and script writing will be the subject of a future column.

Everybody do the Twist

Once you've succeeded in abstracting a twist value from your bone, adding twist fix-ups is pretty easy. Let's look at a common example: a one-link neck (Figure 4). The fix-ups themselves are merely extra bones laid out along the length of the neck. Fix-ups always form a parallel branch of the animation hierarchy rather than an in-line part. Here the fix-up bones are all children of the neck bone, thus, siblings of the head and also of one another. As siblings of one another, the numbers we feed into their twist expressions will have consistent meanings. Before the expressions are added, the fixups' rotations should be zeroed out so they start off aligned exactly with the neck. Each fix-up should be matched to a ring of vertices in the cross section around the neck. In this case three fix-ups seems sufficient to keep the neck from collapsing.

[FIGURE 2 OMITTED]

In this example we have three fix-ups, located at the base of the neck, one-third of the way down, and two-thirds of the way down, respectively. Each fix-up gets an expression of its twist axis, assigning a rotation proportional to the fix-up's position along the length of the bone. We don't want the first fix-up bone (the one at the base, located at zero-third of the way down) to twist at all. The fix-up at one third of the way will rotate 33 percent of the total twist, while the one at two-thirds of the way reaches 66 percent. The remaining 33 percent of the total twist rotation is handled by assigning vertices directly to the neck bone itself, which of course rotates by three-thirds of the way.

The subtlety here is that the fix-ups are actually counter-rotating, reversing the twist of their parent, the neck bone. Therefore, the first fix-up rotates backwards by the whole twist value, the second rotates negative two-thirds of the twist, and so on. The mathematically-minded may express this as follows:


[FIGURE 3 OMITTED]

As you can see, the setup is very simple and can be driven by kindergarten-level expressions. If all you're after is avoiding twist-induced collapses, that's all you need. If you're feeling adventurous, you can tweak the distribution of the twist by changing the rate at which the fix-ups rotate. The previous example is a simple linear distribution: each fix-up's rotations are mapped directly to its positions along the bone. You could compare this to the behavior of an F-curve with linear tangents. Changing that relationship will distribute the twist differently. For example, if the twist expressions were set up as (1--the fix-up's position over bone length, squared) (-1) (bone twist), you'd get a slow start and a sharp end to the distribution of the twist--in other words an ease-out F-curve. Don't be afraid to experiment if you have a particularly difficult piece of geometry or motion. Don't obsess over the math. There's nothing wrong with skipping the formulas and just fiddling with different constraints to get good-looking results.

Let's Twist Again

So far we've tried using counter-rotating fix-ups to remove parts of the rotation from the base of the neck. Often, though, you may want to put twist fix-ups onto a bone that is not itself twisting. Our hypothetical neck bone might be set up with its twist rotation locked, and the twist value could be derived from the rotation of the head instead. The fix-ups will work equally well at preventing collapses. Using a downstream bone to drive the fix-ups involves only two changes to the arrangement we've already described.

The first difference is that the distribution of the fix-up bones is reversed. In our example, we positioned fix-ups starting at the bottom of the neck, since we wanted to remove the twist at the base. If the neck is not twisting, though, we can eliminate the fix-up at the base and assign the vertices there directly to the (untwisted) neck bone. At the same time we'll need to add a fix-up at the upper end of the neck bone that will handle the three-thirds rotation previously left to the neck bone.

The second difference is in the expressions. When the neck was twisting, we needed the fix-ups to counter-rotate against that twist. Now that the neck is not twisting, the fix-ups rotate positively. The fix-up one-third of the way along rotates one-third of the twist value, the fix-up two-thirds of the way along rotates two-thirds, and so forth. The new expressions can be summed up as follows: fix-up rotation = twist times the fix-up's position as a fraction of bone length.

You may ask, why drive the twist with a different bone? This technique is particularly useful for fixing troublesome forearm deformations. Although we conventionally rig characters with ball-joints in their wrists, in reality the wrists have only two degrees of freedom. The twisting motion actually comes above the wrist, from the torsion of the ulna and radius bones in our forearms. Long sleeve can disguise the problem, but bare-armed characters are often afflicted with pinched, robotic wrists or rubbery Gumby-style forearms. Splitting out the forearm twist into a separate bone is cumbersome for FK animation and problematic for IK as well. With twist fix-ups driven by the wrist, though, it's easy to get reasonably good forearms without changing the animation rig at all (Figure 5).

Twist Off

The ultimate challenge for twist fix-ups is our old nemesis: the shoulder. As we have lamented in the past, shoulders are very tough to skin effectively. With a twist range of nearly 180 degrees, shoulders also cause nasty shearing in the upper arm. It doesn't help that the game industry's steroidal mindset creates a lot of characters with gigantic biceps that magnify every twist problem. When we introduced ball-joint fix-ups in February, we noted they can preserve the volume of a collapsed shoulder but don't protect against biceps shearing. Now we can rescue the biceps as well by combining the best aspects of twist and ball-joint fix-ups.

[FIGURE 4 OMITTED]

[FIGURE 5 OMITTED]

Relaxed Shoulder

Ahybrid ball-and-twist approach starts very much like our first example, by adding twist fix-ups to the biceps bone. These fix-ups will rotate backwards against the twist of the biceps bone, as in the first example. The fix-up located on the shoulder, though, works rather differently. Instead of being parented to the bone, it's parented to a ball-joint fix-up, also located at the shoulder. The ball-joint fix-up will produce a weighted average of the shoulder's and clavicle's rotations. The twist fix-up then needs to counter-rotate against the twist component of the shoulder's rotation to remove the twist from the base, just as in the neck example. To do this, the twist fix-up's expression will equal the biceps' twist times-1 times the weight coefficent of the ball fix-up. When assigning vertices, simply ignore the ball-joint fix-up and use only the twist fix-ups. The result of this should be to spread the twist of the arm along the biceps without losing the rotational compensation of the shoulder fix-up (Figure 6). This goes a long way towards preventing the worst shoulder deformation atrocities. The fix-up bone technique we've described here is still only a crude approximation of what really goes on under the skin of a real person. There's no denying it's a hack; nevertheless, it's a pretty useful one and, despite the large chunk of text it takes to describe it, not really very difficult to implement. The biggest handicap is the difficulty of extracting twist data from Max controllers, so if anyone out there has developed good ways of getting those Max numbers, feel free to send them to me. I'll share them when we return to the topic of using Max bones with expressions a few months later.

[FIGURE 6 OMITTED]

STEVE THEODORE | Steve started animating on a text-only mainframe renderer and then moved on to work on games such as HALF-LIFE and COUNTER-STRIKE. He can be reached at stheodore@gdmag.com.

[ILLUSTRATION OMITTED]

Theodore, Steve

Source Citation
Theodore, Steve. "Twist and shout: fixing twisted deformation." Game Developer Apr. 2004: 18+. Gale Power Search. Web. 26 Jan. 2012.
Document URL
http://go.galegroup.com/ps/i.do?id=GALE%7CA115836023&v=2.1&u=22054_acld&it=r&p=GPS&sw=w

Gale Document Number: GALE|A115836023

ArabicChinese (Simplified)Chinese (Traditional)DeutchEspanolFrenchItalianJapaneseKoreanPortugueseRussian

In "A Joint Effort" (Artist's View, February 2004), we introduced the fix-up bones as a means of combating the regrettable state of conventional real-time skin deformation. Fix-ups work by reproducing a fraction of the rotations in an animating skeleton. Assigning vertices to the fix-up bones, rather than directly to the animation skeleton, prevents the worst forms of vertex collapse around problematic joints like shoulders. This month we're going to look at some advanced fix-up strategies for a different class of deformation problems.

Sick and Twisted

The shoulder is clearly the worst villain of skin deformations, but there are many runners-up with different kinds of deformation failures. The most notable contenders are twisting joints. Necks, forearms, and biceps can all shrink or even turn inside out when twisting around their long axes. The problem stems from the same source we discussed in February. As with ball-joints, the skinning algorithm interpolates vertices linearly between their original and newly rotated positions. Naturally the rotation of the vertices takes place along an arc. The interpolation, being linear, always cuts a chord on that arc, slicing deeper into the volume of the model as the twist increases. At 180 degrees the chord passes right through the origin of the arc--in other words, the bone--collapsing all of the vertices down to a point (Figure 1).


The cure for this nasty hourglass effect is to adapt the strategy we used for the ball-joint fix-ups described in the February column. Twist fix-ups rotate around the long axis of a twisting bone by some fraction of the real rotation. They carry their assigned vertices to positions that reflect the correct rotational interpolation. This preserves the volume of the geometry and prevents the hourglass effect.

Doin' the Twist

Unlike ball-joint fix-ups, twist fix-ups only work in a single axis. This means they have to be controlled by expressions rather than constraints. So before we can build twist fix-ups, we need some way of representing the twist as a number that can be fed into an expression. Unfortunately, twisting (like obscenity) is easy to recognize but hard to define. Consider the arm of a typical animation skeleton. Intuitively we know that the twist of the arm is the rotation around the axis between the shoulder and the elbow. Naturally you'd assume that the Eulerangle rotation value for the axis that points along the biceps would be the twist value. The reality, alas, is a bit more complex. Figure 2 shows three sets of F-curves, which produce identical animations. The only difference among them is the order in which the Euler rotations are executed. As you can see, different rotation orders produce remarkably different results.

[FIGURE 1 OMITTED]

How can you get a good twist value then? The source of the problem is that each rotation influences the meaning of the numbers that come after it. Since each rotation changes the meaning of the next, only the first term in an Euler sequence has a stable meaning. Therefore, it's possible to determine the twist of a bone with Euler angles only if the twist axis is the first axis in the rotation order. Before trying to build twist fixups, double check the rotation order on your bones to be sure the axis which points down the bone is the first Euler term (Figure 3). In both Max and Maya the skeleton tools usually create bones this way by default, with the x as the twist axis and the rotation order set to the conventional x-y-z. But be sure to check! Your defaults may have changed, and building skeletons out of disjointed parts can cause unpleasant surprises.

The bad news about deriving twist values from Euler angles is Max's animation-controller architecture makes it impossible to get consistent Euler values from bones driven by IK, constraints, or TCB rotations. For IK-driven bones, the twist angle value on the IK handle is often an adequate substitute and can be fed to twist expressions. Generally, though, the only alternative for Max users is to create a custom twist attribute and animate it by hand. Ferreting information out of Max controllers for expression and script writing will be the subject of a future column.

Everybody do the Twist

Once you've succeeded in abstracting a twist value from your bone, adding twist fix-ups is pretty easy. Let's look at a common example: a one-link neck (Figure 4). The fix-ups themselves are merely extra bones laid out along the length of the neck. Fix-ups always form a parallel branch of the animation hierarchy rather than an in-line part. Here the fix-up bones are all children of the neck bone, thus, siblings of the head and also of one another. As siblings of one another, the numbers we feed into their twist expressions will have consistent meanings. Before the expressions are added, the fixups' rotations should be zeroed out so they start off aligned exactly with the neck. Each fix-up should be matched to a ring of vertices in the cross section around the neck. In this case three fix-ups seems sufficient to keep the neck from collapsing.

[FIGURE 2 OMITTED]

In this example we have three fix-ups, located at the base of the neck, one-third of the way down, and two-thirds of the way down, respectively. Each fix-up gets an expression of its twist axis, assigning a rotation proportional to the fix-up's position along the length of the bone. We don't want the first fix-up bone (the one at the base, located at zero-third of the way down) to twist at all. The fix-up at one third of the way will rotate 33 percent of the total twist, while the one at two-thirds of the way reaches 66 percent. The remaining 33 percent of the total twist rotation is handled by assigning vertices directly to the neck bone itself, which of course rotates by three-thirds of the way.

The subtlety here is that the fix-ups are actually counter-rotating, reversing the twist of their parent, the neck bone. Therefore, the first fix-up rotates backwards by the whole twist value, the second rotates negative two-thirds of the twist, and so on. The mathematically-minded may express this as follows:


[FIGURE 3 OMITTED]

As you can see, the setup is very simple and can be driven by kindergarten-level expressions. If all you're after is avoiding twist-induced collapses, that's all you need. If you're feeling adventurous, you can tweak the distribution of the twist by changing the rate at which the fix-ups rotate. The previous example is a simple linear distribution: each fix-up's rotations are mapped directly to its positions along the bone. You could compare this to the behavior of an F-curve with linear tangents. Changing that relationship will distribute the twist differently. For example, if the twist expressions were set up as (1--the fix-up's position over bone length, squared) (-1) (bone twist), you'd get a slow start and a sharp end to the distribution of the twist--in other words an ease-out F-curve. Don't be afraid to experiment if you have a particularly difficult piece of geometry or motion. Don't obsess over the math. There's nothing wrong with skipping the formulas and just fiddling with different constraints to get good-looking results.

Let's Twist Again

So far we've tried using counter-rotating fix-ups to remove parts of the rotation from the base of the neck. Often, though, you may want to put twist fix-ups onto a bone that is not itself twisting. Our hypothetical neck bone might be set up with its twist rotation locked, and the twist value could be derived from the rotation of the head instead. The fix-ups will work equally well at preventing collapses. Using a downstream bone to drive the fix-ups involves only two changes to the arrangement we've already described.

The first difference is that the distribution of the fix-up bones is reversed. In our example, we positioned fix-ups starting at the bottom of the neck, since we wanted to remove the twist at the base. If the neck is not twisting, though, we can eliminate the fix-up at the base and assign the vertices there directly to the (untwisted) neck bone. At the same time we'll need to add a fix-up at the upper end of the neck bone that will handle the three-thirds rotation previously left to the neck bone.

The second difference is in the expressions. When the neck was twisting, we needed the fix-ups to counter-rotate against that twist. Now that the neck is not twisting, the fix-ups rotate positively. The fix-up one-third of the way along rotates one-third of the twist value, the fix-up two-thirds of the way along rotates two-thirds, and so forth. The new expressions can be summed up as follows: fix-up rotation = twist times the fix-up's position as a fraction of bone length.

You may ask, why drive the twist with a different bone? This technique is particularly useful for fixing troublesome forearm deformations. Although we conventionally rig characters with ball-joints in their wrists, in reality the wrists have only two degrees of freedom. The twisting motion actually comes above the wrist, from the torsion of the ulna and radius bones in our forearms. Long sleeve can disguise the problem, but bare-armed characters are often afflicted with pinched, robotic wrists or rubbery Gumby-style forearms. Splitting out the forearm twist into a separate bone is cumbersome for FK animation and problematic for IK as well. With twist fix-ups driven by the wrist, though, it's easy to get reasonably good forearms without changing the animation rig at all (Figure 5).

Twist Off

The ultimate challenge for twist fix-ups is our old nemesis: the shoulder. As we have lamented in the past, shoulders are very tough to skin effectively. With a twist range of nearly 180 degrees, shoulders also cause nasty shearing in the upper arm. It doesn't help that the game industry's steroidal mindset creates a lot of characters with gigantic biceps that magnify every twist problem. When we introduced ball-joint fix-ups in February, we noted they can preserve the volume of a collapsed shoulder but don't protect against biceps shearing. Now we can rescue the biceps as well by combining the best aspects of twist and ball-joint fix-ups.

[FIGURE 4 OMITTED]

[FIGURE 5 OMITTED]

Relaxed Shoulder

Ahybrid ball-and-twist approach starts very much like our first example, by adding twist fix-ups to the biceps bone. These fix-ups will rotate backwards against the twist of the biceps bone, as in the first example. The fix-up located on the shoulder, though, works rather differently. Instead of being parented to the bone, it's parented to a ball-joint fix-up, also located at the shoulder. The ball-joint fix-up will produce a weighted average of the shoulder's and clavicle's rotations. The twist fix-up then needs to counter-rotate against the twist component of the shoulder's rotation to remove the twist from the base, just as in the neck example. To do this, the twist fix-up's expression will equal the biceps' twist times-1 times the weight coefficent of the ball fix-up. When assigning vertices, simply ignore the ball-joint fix-up and use only the twist fix-ups. The result of this should be to spread the twist of the arm along the biceps without losing the rotational compensation of the shoulder fix-up (Figure 6). This goes a long way towards preventing the worst shoulder deformation atrocities. The fix-up bone technique we've described here is still only a crude approximation of what really goes on under the skin of a real person. There's no denying it's a hack; nevertheless, it's a pretty useful one and, despite the large chunk of text it takes to describe it, not really very difficult to implement. The biggest handicap is the difficulty of extracting twist data from Max controllers, so if anyone out there has developed good ways of getting those Max numbers, feel free to send them to me. I'll share them when we return to the topic of using Max bones with expressions a few months later.

[FIGURE 6 OMITTED]

STEVE THEODORE | Steve started animating on a text-only mainframe renderer and then moved on to work on games such as HALF-LIFE and COUNTER-STRIKE. He can be reached at stheodore@gdmag.com.

[ILLUSTRATION OMITTED]

Theodore, Steve

Source Citation
Theodore, Steve. "Twist and shout: fixing twisted deformation." Game Developer Apr. 2004: 18+. Gale Power Search. Web. 26 Jan. 2012.
Document URL
http://go.galegroup.com/ps/i.do?id=GALE%7CA115836023&v=2.1&u=22054_acld&it=r&p=GPS&sw=w

Gale Document Number: GALE|A115836023

Personalized MY M&M'S® Candies
ArabicChinese (Simplified)Chinese (Traditional)DeutchEspanolFrenchItalianJapaneseKoreanPortugueseRussian
(Web-Page) http://dinosaur.hunter2008.googlepages.comHoliday 2008
Lowest Prices and Hassle Free Returns at WWBW.com(Album / Profile) http://www.facebook.com/album.php?aid=10031&id=1661531726&l=cf90f7df9cShop the Official Coca-Cola Store!Email: leonard.wilson2009@hotmail.comWal-Mart.com USA, LLC

No comments: