Thursday, August 29, 2013

Zero out Rotation Axis in Maya

A small but niggling problem with Maya rigging comes about when orienting joints. If (like me), you like to adjust your joints' local rotation axis by using component mode, you will notice that once you finish, the rotation will follow the new local rotation axis, but the translate won't. This can cause problems for moving joints and animating further down the track.

The problem arises from the fact that Maya stores changes to the local rotation axis in a special attribute on your joint called "Rotate Axis". When you finish your skeleton, you should always have zeroed Rotate Axis values:

By zeroing out the Rotation Axis value of a joint, you can make that everything is working correctly when you finish rigging and are ready to animate. You can think of it as a type of "freeze transform" for joint orients.

Let's take the following example:

  1. The spine directions do not match, even after orienting joints.
  2. The direction has been fixed by going into the component editor,  selecting the joint and rotating it 180 degrees in x using the following MEL snippet:
  3. rotate -r -os 180 0 0;

  4. Back in object mode, the rotation is now correctly facing the same way on all joints.
  5. However the translate is not. Select all the joints and use the following piece of MEL to zero out the joint's Rotate Axis value:

  6. joint -e -zso; 

  7. Now everything is correctly aligned to the local rotation axis value.
Alternatively, you can download the oc_jointOrient script to do the job:
It also has a handy right click feature which allows you to rotate discretely without having to type in any MEL:

Monday, August 19, 2013

50% Grey Midpoint in Maya Diplacement

Maya displacement is something that I avoid using as much as possible.

I've always maintained that my reluctance is because I don't have much experience with sculpting (Though I've used Mudbox a little bit), and that no matter how I do it, greyscale displacement maps never look as nice as a normal map.

That being said, I've discovered that greyscale normal maps don't import into Maya correctly (to my view).

Logically, I would expect a value of 50% grey to not change the displacement of an object at all, while white would be the equivalent of 100% displaced up, and black 100% displaced down.

Maya by default takes black as no displacement and white as 100% displaced up.

In order to fix this, you need to put the following formula into the Alpha Offset slot of the file node which holds the displacement image:
Where %FILE% is the name of the file node (or texture node if you're not using a file). We use the value of -.5 to shift the midpoint down 50% from white to mid grey. 

Your displacement should now work correctly.