Jacob's Blog Buttons (custom HTML)

digital art

Monday, October 7, 2013

Animated Facial Features with Pupil

I recently received an email asking about moving a pupil around with the animated texture.  (Thanks for the email, Tom.)

The solution I came up with was using the same offset trick for the eye frames, and then using offset to control the pupil under the eye.  A LERP blended the two together.  It actually ended up being a simpler layout than I had anticipated:

The first Place2DTexture would control the offsets as shown in the the first tutorial to change eye shape, blinking, etc.  The second Place2DTexture would control the eyeball offset, which would cause the pupil to move around 'under' the mask.

The problem, though, was that I could do this in UDK or Maya, but not in Unity.  I'm not familiar enough with materials in Unity to work without a visual editor.  Strumpy Shader is a great node based editor for Unity, but it was designed to work in Unity 3.x, and isn't supported anymore.

Tom came up with a clever solution; he used an additional plane for the pupil.  The back plane had the eye outline (with lashes and the like) and the sclera colored in.  The front plane had the pupil and sclera color, with a mask applied over it that matched the shape of the sclera of eye in the back plane.  As a result, it was a very functional solution that worked very similarly to using a lerp, but it didn't require any special shader system.

If you wanted to keep the animation on the joints, controlling the pupil with either system would just require a script to handle rotation on the joints.  Say, when it rotates on Y to +/-180 , it offsets the left-right a set amount, and when it rotates on Z, offsets the up-down; the X will always point in the direction it's looking.  An aim constraint in either Maya or Unity (say, if you wanted dynamic eye direction) could drive the rotation on the existing joints, and the script would go from that information.

No comments:

Post a Comment