Saturday, July 27, 2013

Hiatus for home renovations

This blog is on a little bit of a hiatus while I do some home renovations, which are eating up all of my time outside of work.  In another week or 2 I'll be back at it to continue this series of posts!

Saturday, July 13, 2013

Character Deformation

Today I'm going to expand on what I went over in Relative Joint Placement and start applying it to some real character deformation.  I'll be focusing on the upper body, but the same principles apply everywhere in a mesh, the only difference is which way the joints are rotating, and what verts you have to work with.

Last week's post went over how joint placement affects deformation and why.  This week I'm going to look specifically at the relationship between where a joint is placed and where the verts are placed and what we can do to create the feel of linear motion, so lets get right into it with an elbow.  I want to start here because it's very simple and I see a lot of games try to cheat this deformation by letting the arm loose volume, killing the feel of muscle and tendon beneath the surface.

Modeling for deformation:


A little tangent, any joint should have at least 4 accompanying edge loops in order to bend and twist.  It needs at least 2 for deformation and 2 for holding volume, 1 pair on each side.  More is nice, but without 4 you'll have to start sacrificing volume and quality.

              

In the elbow above the red tics mark the deformation edges with the yellow marking the volume holding edges.  Take a close look at the placement of these edges in relation to the joint, the upper arm deformation edge is placed very close to the center line of the joint.  As the joint rotates we want to loose as little volume as possible in the inside of the upper arm.  The further away from this center point that we place this edge loop the faster it will move into the mesh as the elbow rotates.(Remember the cylinder from last week)  We minimize the volume loss by keeping it very close to the center of the joint.  However, we have to be sure not to move it to the other side.  The elbow side of this loop needs to hold volume and will behave in the opposite way as the inside.  So while the inside is loosing volume, the elbow side will gain volume, if the inside was gaining volume the elbow would loose it.  We need the elbow side to gain volume first in order for it to wrap around the elbow joint without squashing and stretching much.  This is also why we favor the joint placement towards the elbow, like we saw on the cylinder when the joint is closer to the mesh surface the surface will squash and stretch less.  In order to keep the elbow feeling like a bone we need it to stay solid(hold volume!) while the inside of the elbow compresses.

The same idea follows through with the deformation edge in the forearm.  As the elbow joint rotates it will first add volume in the forearm before loosing it as the elbow rotates further, ideally evening out over about 45 degrees.  We can tone this volume gain down with weighting to the shoulder joint, but that's a topic that will get it's own post.  The exact placement of this edge relies on the placement of the upper arm deformation edge loop, which brings us to the next set of pictures.

                

Above is a very close up look at the inside of the elbow, shoulder is screen up.  The first picture shows what we're trying to accomplish, we want the forearm vert to travel along the edge/polygon and touch dead on to the upper arm vert.  The problem is, that's not how they are moving, both of these verts are rotating at different speeds and in different arcs.  Getting these verts to touch is tricky and we need to pay close attention to the principles of joint and vert relationships to get them dead on.  This is also where we need to look at changing the model to fix the deformation and not the joints or weighting.   When the edges are first placed, no matter how you set the weighting, you'll most likely get something like this.



The verts move right on by each other, leaving a V shape in the mesh.  When these 2 verts touch it will feel like the forearm vert traveled straight along the polygon to get to the upper arm vert even though they are both rotating around the same point.  It's this trick that creates linear motion from rotation, matching the rotations so that the verts will meet.

Now, how do we fix this?  First, this is more often a vertex placement problem and not a weighting problem.  However, it is a good idea to try to fix it with weighting, but don't spend a lot of time if the weighting isn't getting you there quick.  We need to think back to the base principles of deformation.  The further away from the elbow joint the vert is the more volume it will add since it will need to arc out away from the vert for a longer time.  Since the vert is out away from it's target that means we've added too much volume.  So, the simple answer is move the edge loop a little closer to the elbow joint.  Once we get the position of the forearm deformation loop right here's what we get.


We can take this one step farther and get the volume holding edge loops to come close to touching as well, which will help a large deformation as the arm goes past 45 degrees and the inner eblow really compresses on itself.  Having the volume edge loops land close to each other will help hide the mesh crashing and cut down on feeling like one part of the mesh is cutting into the other, which helps it feel like the meshes are compressing together instead of crashing through each other.

Take care until then!

Wednesday, July 10, 2013

Back to Basics, Part 1

I've realized that a lot of what I plan on writing about relies on an understanding of what rigging is and how to create a good functional rig.  If you already have a working knowledge of rigging these back to basics posts will be a lot of simple review, and hopefully for others they will help you understand the bigger picture when I am talking about things like a deformation skeleton.

I thought I'd start this off with a checklist of things to look at when creating a bind skeleton and each of these posts will cover the details of one of the items in the checklist.

First, a bind/deformation skeleton is a hierarchy of joints starting at a single root joint.  These are the joints that the mesh/s will be bound to for a character, creature, or prop.  It's important to keep separation between your bind skeleton and rig in order to isolate the animation to the rig.  When the skeleton is detached from the rig it will return to bind pose and you can continue to make joint adjustments and re-attach the rigging with minor work instead of needing to throw away and remake rigging to make changes

Checklist :

  • Joint Placement  
  • Orientation
  • Rotation Order
  • Mirrored Joints
  • Names

The current series of weekend posts is covering joint placement so I'll jump right into joint orientation.

Orientation - To see the rotation axes in Maya select the joints and go to the Display menu -> Transform Display -> Local Rotation Axes.  Each joint chain poses it's own challenges

To work with orientation Maya has the Orient Joint tool, which has a UI that isn't terribly intuitive.


Orient Joint to World : This name lies.  Selecting this will orient the joint you have selected to match the orientation of it's parent.  If the joint doesn't have a parent it will orient the joint to match the world.  Un-parented objects are considered to be parented to the world.
Primary Axis : Defines which local rotation axis will point directly at the child of the joint.  If the joint has multiple children Maya will choose the first object that was parented to it.
Secondary Axis : This option and 'Secondary Axis World Orientation' work together. The secondary axis is the axis you want to point in the direction of the 'Secondary Axis World Orientation'.
Secondary Axis World Orientation : Which direction in the world do you want the secondary axis to point?

The 3rd axis is along for the ride, and often the secondary axis won't point exactly in the direction of the secondary axis world orientation.  This is because orient joint uses an aim/lookat constraint calculation, which I plan on covering in detail, but the math behind it deserves it's own post.  For now, the secondary axis will point as close to the direction you tell it to that it possibly can.

So, how should joints be oriented?  There's plenty of debate over what's best and why, I can only show you what works best for me.  The one common behavior I keep to is that any joint at the end of a chain is oriented to match it's parent.


   


Spine :

 I break convention with my spine, neck, and head and leave them completely oriented to the world, the easy way to do this is place them one at a time and then parent them manually.  You can also change your joint tool orientation settings to have Orient Joint to World checked before creating the chain.  I do this so that the local twist rotation of the spine neck and head follow the length of the body instead of the curvature of the spine, it gives a natural motion and prevents the local twist rotation from skewing forward or backwards.

Arm :

As with any joint chain that will eventually have an IK driving it the placement and orientations must be precise for the IK solve correctly and keep the arm bending on a perfect plane.  All joints must sit on the same plane, you need to have a primary axis pointing along the length of the chain and each secondary axis must lay across the same plane.  To quickly check this you can create a polygon plane, point and orient constraint it to the elbow, and scale it out to match the length of the arm. If any axis is pointing down through or up away from the plane your IK won't solve correctly.


Fingers :

The only important part here is that every finger should be consistent, if you grab every finger joint and rotate them in they should all curl into a loose fist without needing to rotate either other axis.  The thumb always needs to be placed differently than the other fingers to get this behavior.

Legs :

Legs are the chain that will try to trick you if you place the joints from a side view.  Because of how Maya works out the joint orientations when placing joints you'll often get a knee joint that has a flipped axis(Maya picks the secondary axis world orientation differently based on if the primary axis is pointing positive Z or negative Z in the world).  Go over the leg with the orient tool to straighten out the knee and set the toes to orient the same as the foot.  Like an arm, the leg will also usually have an IK so make sure the hip, knee and ankle are oriented along a plane.

And do your best to rig with a straight leg from hip to foot.  If the character design calls for bowed legs or other awkward poses consider letting the rig deform the character into that pose.  Model and rig the legs straight and set a default pose in the rig to start animations from using null objects to keep rig controls zeroed out in the default pose.  I'll have more on the details of doing that farther down the line once I'm done covering deformation.


For now I hope you enjoyed this first look at some of the basics of rigging and controlling your joint orientations.


Friday, July 5, 2013

Relative Joint Placement

I'll say that joint placement is the foundation of good character deformation.  If the joints of the deformation skeleton aren't given a lot of thought you'll quickly find yourself in a position where no matter how good you make the rig, no matter how much time you put into weighting, you still won't be able to get excellent deformation.  But joint placement alone doesn't mean a whole lot, it's the relationship between the joints and the mesh verts that matters most.  In my experience models need to be changed just as much as joint positions in order to get everything set into place for deformation, and even the smallest change can have a large result.

That said, we need to look at why joint placement matters, which is going to be a pretty common theme in my posts.  I love knowing the gritty details of what I'm working with and that's the kind of information I'm hoping to pass along.  So, first lets look at the simplest case possible, a joint and a vert.  In the picture below I have a joint with a single vert weighted to it.  In both, the joint is rotated close to 30 degrees and I put in a nurbs sphere wireframe to show a quick display of the full path that vert will take as it rotates around the joint.



As you'd expect, changing up the position of the joint relative to that vert gives us drastically different motion.  On the left the vert is moving away from the surface of the mesh, on the right it's moving into the mesh.  I know this sounds very simple, but we have to look at 2D to understand why it's important.  One of the main principles of 2D animation is squash and stretch and a key to squash and stretch is preserving volume.  In 2D the animator has full control of their character's volume but this doesn't hold true in 3D.  Without specific rig controls the animator has no control over the volume.  It's the job of the person weighting the character to make sure that deformation is preserving volume, when the vert is moving away from the surface of the mesh we're gaining volume, when it's moving into the mesh we're loosing volume.

The second principle in how the relationship between a joint and it's verts affects deformation is the distance the joint is from the vertex.  In the picture above the joint is exactly the same distance from the vert on both sides, only the relative vertical position has changed.  In this next image the weighting is identical between the left and right, as is the vertical position of each joint.  The only difference is where the joint chain sits inside of the mesh.



Again the deformation we get is considerably different.  The further a vertex sits from a joint the further it will travel with each degree of rotation from that joint.  On the left side of the left mesh and the right side of the right mesh there's only a minor change in the spacing between each vertex compared to the un-deformed spacing that you can see at the top and bottom of the cylinder.  On the right side of the left mesh we get a fair amount of stretching.  On the left side of the right mesh we get very tight compression.  The stretching and compression are because of the extra distance that each one of those verts is being moved by the same rotation.

I know these are very simple ideas, but they are the core of what we need to make the circular motion of the animation feel like linear motion on a mesh.  Next week I'll start getting into how to make use of these 2 principles to take control of character deformation.

Wednesday, July 3, 2013

A little diversion

I'm going to take a small step back for a moment to talk about what makes good deformation in a character, and what a technical artists' role is to get those results.  The deformation skeleton and weighting are only half of the solution in getting a mesh to move, we also have to closely consider the model and the animation.  When setting up a character we need to keep a critical artistic eye on both of these areas.  The first thing I do when setting up a model is look at the joint placement and topology and find the flaws in a mesh that won't deform right.  If I can fix problems without aesthetically changing the model I'll do it, if not I'll find the character artist and make a request to get it changed.  I'd say 9/10 times the changes are minor and plenty easy to change on our own.  Same goes with animation, there are times where animations or in game driven systems will put your character into impossible positions that break the weighting.  Sometimes the animation needs to be looked at and not the weighting to fix the problem.

One of the most important skills of a technical artist is communication.  It can sound a little cheesey but our job is to combine the technical side of game development with the artistic side and we need a good rapport with programmers and artists to do that   Sometimes this means requesting model and animation changes, other times it means talking with animation or game engineers to solve a problem or get a new feature.  It's when we keep communication open between departments that we find the best results.

It's this iteration and communication that lets us effectively do our jobs, and without it quality will always suffer.  Next weekend I'll have my post up about what it means to look at joint placement and topology and how I set up their relationships to get the best deformation that I can.