Monday, July 20, 2009

After Effect Expression... Birds Eye View

Since the Basement is half Motion Graph and half interactive, I've been trying to get my hands dirty on the Mo Graph side by learning some Expressions that could help in After Effects.

Resources:
1. I read through Adobe's help and API. Its a great place to start, but don't expect much from the API.
2. I read through Marcus Geduld's After Effect Expressions, which was a decent, quick read for beginners... more geared towards non-programmers though. A few of the programming examples made me cringe, but its ok, it was helpful in figuring out the layout and rules of the road.
3. I then went to Dan Ebberts's MotionScript.com and ran through some of his tutorials. There is a lot of overlap between MotionScript and Geduld's book, you are probably better off just checking out the website and skipping the book.

After all of that, here is what I've figured out:

1. Its based on javascript so Flash devs will feel right at home.
2. You can apply any math/physics to any property. Just think Keith Peter's ActionScript Animation minus the mouse/keyboard interaction.
3. Instead of interacting with the mouse... you can tie properties of compositions/layers/effects to each other. So if a butterfly's wings rotate down, you could make the butterfly's body move upwards to simulate thrust.
4. AE makes tying properties together very easy. There is a tool called a "Pick Whip" that makes it as simple as dragging and dropping properties onto either other.
5. However, you need to be careful when tying properties together since properties can return different number of variables... for example "rotation" may have 1 value while "position" may return [x,y].
6. You can't create new layers on the fly. If you wanted 100 butterflies to flock, you would need to create one, place the code on it and then duplicate the layer 99 times... imagine needing to make a change, yuck.
7. Expressions that are coded on one property can not be accessed from another property, nothing is global or even public. For example: if we make a variable called "id" on layer 1, we could not access layer 1's "id" from layer 2. Expressions on each layer live in their own sandbox.
8. Expressions live and die on each frame and have no memory of the previous frames. Now this one is interesting. You can't declare a "counter" on frame one and hope to increase it on frame 2. When the expression on frame 2 executes, it will throw and error because it will not know what "counter" is, even though it was declared on the SAME layer just one frame beforehand.
9. At first I thought this was a huge limitation... however, there are many built in functions for figuring out time, frame number, etc which allow you to script across a timeline.
10. One cool aspect is that you can access a property's value at a specific time (a time that is not the current time). This is actually kinda cool, you can use a future value of another property to impact your current position... something not possible in Flash since future values are unknown.
11. They also added the ability to give random numbers a "seed" to ensure that you get the same random number when you use the same seed. As long as you know the seed, you will get the same results across multiple frames. A little wonky, but it works. And yes, I used the word wonky... I am surprised you are still reading this far to be honest ;)

Summary:
AE Expressions are nice for syncing properties and adding physics, but it has far too limited sandbox to make anything beyond a neat effect. The real power of scripting can be found in the Extend Script and the Patch Panel. Those are next on my research list.

3 comments:

Lawrie said...

Thanks for this interesting write up. I've been meaning to play with AE Expressions for a while, but never found the time.

I'd love to make some generative videos from code alone, and I'm not too impressed with the video export from Flash. I guess I'll wait and see how your Extend Script and Patch Panel tests go.

Have you (or anyone at the Basement) done any video tests with Processing? Along the lines of Glenn Marshall (http://www.vimeo.com/user656427) or Robert Hodgin (http://www.vimeo.com/flight404)

Seems like it could be the way forwards for script based motion graphics :)

Haruk said...

About #6 I believe there is a way to have duplicates of an item and make easy changes to all of them.

If you had a layer and set it up, then you "pre-compose" the layer. You can duplicate the new composition (in the layer) and if you make changes to the original, I believe they all update.

(I'm just learning AE so I could be incorrect...or just badly wording things)

Ickydime said...

@Lawrie
thanks for the links. I had not checked out their work. very impressive. guess I will add that to my list as well ;) Another thing to check out is "openFramework". I have seen some impressive work done with that... its C based instead of java. Check out Dr. WooHoo

@Haruk
You are probably right. I couldn't imagine people having to reduplicate work all the time... especially if other pieces depended on the originals.