Wednesday, October 3, 2018

Unity's Additive Animations Not Working? Here's a Fix

Unity's Additive Animation system allows you to blend layers of animations together. So on one layer you could have your run/walk animations, then have an additive layer above this with different turn poses or different exhaustion states. In theory. Because right out the box the Additive Animation system keeps some information hidden from you that makes working with them difficult/right out makes them not work: you need Additive Animation Reference Poses.

What Unity expects you to do is add a frame of T-Pose at the start of every single animation you want to use as an additive animation, and... You can quickly see how this quickly gets tedious and makes testing animations more laborious.

I recently discovered a work-around for this, though, allowing you to use any other animation clip as your reference clip without having to muck around with adding T-pose frames or scripting:

  1. Duplicate the animation clip out from your imported animation (this is to get around the original being Read-Only)
  2. Select the duplicated clip and set the Inspector window to Debug mode, in the menu on the top right corner
  3. Open up the collapsed Animation Clip Settings menu, there you will see an field called Additive Reference Pose Clip. Drag and drop or select an animation clip to set as you reference pose here
  4. Set the "Additive Reference Pose Time" to the frame you want to be your reference
  5. Check off the "Has Additive Reference Pose" box
  6. You're all set, enjoy hassle free additive animations!

This can be done with multiple animations selected, making the process that much quicker.

Tuesday, March 6, 2018

Unity Shader: Adding a Gradient Overlay

Let's get right to it. Here's the shader, in all its amateurish glory:

But why use this?

A gradient is a great way of focusing attention, either towards the bottom or the top of an element. In the example below, the gradient was used to focus attention on the main street area. Additionally, it was be used to fake street-level lighting by darkening the tops of buildings and to add a feeling of cohesion between the sky colours and environment colours (like a vertical "fog").
Buildings with gradient

By changing the the value of screenPosition from Y in the highlighted section, we can change the direction of the gradient.
Oh, the places you can go

Now, this is a fairly limited shader that I created for a very specific use-case in a project. So there are some blatant improvements to be made to it:
  • Despite being named "Standard (Gradient Overlay)", it is missing many properties before actually matching Unity's Standard shader
  • The shader is in screenspace, so any camera movements on the same axis as the gradient will affect the appearance of the gradient
  • The emissive in on by default, blowing out the gradient. So if it looks like it's not working... Try changing the emissive colour to black first
  • There's no snazzy custom editor for it
Next time (eventually): improving the gradient shader.

Thursday, February 22, 2018

Hello World!

Welcome to my blog, where I hope to document my slow, painful transformation from a 3D Artist to a semi-competent Technical Artist! Thanks for stopping by, maybe someday you'll find something useful here.