Jacob's Blog Buttons (custom HTML)

portfolio
animation
character
digital art

Saturday, March 29, 2014

Sneak Peek at Animated Facial Textures Script Update


Centering on texture and pupil secondary-offset control.
Tile offset, U and V tweaking, working all in one!

I am currently working on a Version 2.0 of my Animated Texture Offset script.  The biggest things I am adding are the option to choose the attribute to read in (position, rotate, scale, X, Y, Z) and support for pupils as mentioned in this post.

Choosing the attribute-in was something I had thought about when I was writing the first version, but it adds a significant amount of complexity to the process, though mostly on the Maya end.  That's actually why I'm writing the Unity C# script first.  I might have to do some weird fanagling with some local variables Maya's Expression Editor.  It could be on the simple side, of setting some variables and copying a script in, or it could be much more than that.

The second bit, the pupil animation, is actually easy to do in Maya.  I was originally going to write a second script to focus on a single pupil texture and offsets with that, but I realized I could merge it with the tiling texture script, allowing for multiple pupil types, as well as keeping it all in one package.  It makes the math significantly more complex, and the script a little harder to read, but it functions just fine.  The one reason it will be more difficult in Unity is because Unity's default shaders take RGB and A all in one channel, so I can't separate out the Place2DTexture of the diffuse and opacity.  I think the solution to that is to include with the script a custom shader that separates out those two maps.  At least that will be easy to write.

On top of those two things, I also refactored the code to just make it a little cleaner and a bit more robust.  The Inspector public variables are much nicer (for example, it takes a GameObject now, rather than a string name), and I have some good error checking in there.