Jacob's Blog Buttons (custom HTML)

portfolio
animation
character
digital art
Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

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.



Sunday, December 8, 2013

Faked Pixel Aesthetic for Unity

A buddy of mine was working on a game concept, and he wanted a pixel aesthetic.  I did a test over some existing animations to see how well Unity 2D could look for pixel art, and I was actually pretty impressed and how well the look carried over.


This is also a sneak peek of the RR four main enemy types (one more coming), and how their idles are turning out.

For a quick breakdown on how I set it up, click "Read more »"

Tuesday, December 3, 2013

Fix for Unity 2D Not Displaying Translate Manipulator

This is a pretty simple one, but it wasn't obvious to me.  I had to ask about it on the Unity forums.

I was working on my animation in a 2D perspective by clicking on the view cube arrow to give me an orthographic camera.  I'm not sure what I did, but my manipulator went missing.  I couldn't move the objects around anymore.  It turns out, I hit the "2D" button, which flattens it to a true orthographic camera, and then, for some reason, gets rid of your manipulators.  Just toggle it off, and you'll get everything back, just fine!

Check out these pictures for a visual explanation of my issue:


Tuesday, November 19, 2013

Tutorial - Using Unity 2D's Dope Sheet for Animation

This tutorial is for anyone who wants to jump into Unity and get to animating sprites in-editor.   It assumes a basic knowledge of Unity, and goes over some of the new Unity 2D features -- enough to get animating.


Getting up to speed took a little time and experimentation with the Unity 2D Demo project, as well as the videos released by Unity.  I thought I might document it here for anyone who needs this information specifically.  For reference, here are the two Unity 2D demo videos currently available:
http://www.youtube.com/watch?v=B1F6fi04qw8
http://www.youtube.com/watch?v=4qE8cuHI93c
You can find a lot more information about Unity 2D there, on top of the information covered in this tutorial.


Click 'Read More' below to see the full document.

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.

Friday, July 26, 2013

Animated Facial Textures in Maya and Unity

Download the pdf document here:
Direct link

Check it out online here:
Animated Facial Textures in Maya and Unity - Full Document

You can check my further notes on the subject here:
More on Animated Facial Textures

Essentially, my goal was to create a texture-driven facial animation system that worked in both Maya and Unity.  Making one in Maya is very simple, but I found very little on getting it to work in Unity, and nothing about getting it to export from Maya.

To give a bit of a background, for FIEA, one of our assignments was to document or write a tutorial about something we learned or wanted to learn.  I took this opportunity to pick up Unity, and solve a possible problem for a game I will be working on soon, and a problem I'd been curious about since when I was working on Intrepid.


I came up with a solution using joint animation that can be baked out of Maya and used in Unity.  The Maya portion gave me some practice with Maya Expressions, which is great considering I want to rig up the rest of the character soon.  And the Unity portion gave me a chance to learn Unity, and also learn some C#.  C# wasn't too difficult to pick up, having studied C and Java in the past; the code to get it all working can pretty much be copy-pasted from the document.

Download the pdf from the link above.  It should be very accessible - it breaks it down really small to start; getting it in engine, and how the math of the expressions and the image offset method will work.  And in sections 4 and 5, it gets to the meat of the whole operation.

If anyone has any questions on how it works, or why I did something; or any comments on how I can improve this method, I'd love to hear it.  Send me an email, or drop me a message here.

Animated Facial Textures in Maya and Unity - Full Document

Click 'Read More' below to see the full document.

Thursday, June 27, 2013

Aiming Pole Vector Controls at Joints

I was adding pole vectors onto knees for a rig I'm currently animating to, and I was using aim constraints to get the curves to point towards the knees (since the knees are not pointing down any one axis).  Then I had the idea: why not leave the aim constraints on?  The pole vector curve will always point towards the joint, so no more losing similar-looking curves in a tangled mess of a bent-over-rig.


 You can also lock out the rotation, and hide them, if you choose, which will stop the animator from keying it, but not restrict the constraints from changing the values.  Perfect for this application.  It's got all of the benefits from drawing a curve between the PV to the joint, but less of the visual clutter (heck, you could even do both).


Safe from we animators, for another day.

Tuesday, May 14, 2013

Using a Rivet Script with Overlapping UVs

When working on my facial rig test, I ran into the problem where I had overlapping UVs, which caused issues in the script.  My solution was to move the overlapping UVs into a different UV quadrant.  Since the texture tiles at a 1:1 ratio, moving the UVs into the (-x, y) quadrant means they function the exact same, but their coordinates are different for the sake of the script.  Clever.

I used the djRivet script for Maya.