Apr 9, 2011

After Effects - 3D Glow, LookAt Expression and Face Camera

That's right! 3D Glow!
I was working on an Iron Man-ish HUD and needed some of the objects to glow. One problem I had is that whenever the camera turned you could see that the glow was actually very flat. I eventually found a solution, and in this post I'll explain how I came to the conclusion, how to use the 'lookAt' expression, and give out a preset from the upcoming Presets Pack. :-D

As we all know, all objects in After Effects are flat 2D, and the 3D only means that it adds the Z-axis to work with. So, as a camera turns and we have a flat solid with a heavily feathered mask, you start to see how flat the 'glow' really is.
In the example below, I have two circular elements that I would allow to look 2D (or 2.5D) and have a camera rotating with some keyframes. The objects are still in as far as their transformation is concerned. I need them to have constant glow that adds to that 3D dimension. But here's what happens when the camera turns:

As you can see, the "glow" looks very flat, and you can actually see its position in 3D space. Which sucks! So how would we make the blur look uniform?

At first I thought keeping it flat would resolve my problem. It did when I set the glow back to a 2D layer and it remained in the centre. However, when the camera panned and the layer went out of view, the glow would remain in the same position: in the centre of the screen::

Ordinarily, it should at least follow the object even slightly, at least.

It's may be something unlikely to happen (and some keyframing could probably fix it), but I dread how every time I change my camera move I'd have to change those keyframes. I want to resolve this once and for all.
So, I went into the Using AE PDF and searched an expression I had heard of once but never gotten around to using: lookAt. (page 626)

""Argument type: fromPoint and atPoint are Arrays [3].
The argument fromPoint is the location in world space of the layer you want to orient. The argument atPoint is the point in world space you want to point the layer at. The return value can be used as an expression for the Orientation property, making the z axis of the layer point at atPoint.""

Basically, lookAt makes a layer FACE another layer. In this case, I can use lookAt to make the glow always look at the camera.
According to the Help, it says you must define a fromPoint and atPoint. The point to look from, the point to look at.
So I headed into its orientation and typed this:


So the fromPoint is position, which is the position of the current layer, and the atPoint is the Camera's position ( thisComp.activeCamera.position ).

This immediately resolves the problem:

What AE does is that although the position of the objects in 3D space aren't changing, the position of the camera is. What the layer is doing is now rotating so that it's always facing the camera :-D

So, I'm sorted out... until I went and added a Null "Camera Control" to handle the camera, then I noticed another problem.
When parenting takes place, the Position values become relative. This means that the lookAt is now using [0,0,-1000] instead of [240,360,0]

So now the rotation's gonna get weird!
Now, we all know that working without a Null is nearly impossible, so we need some code using the toWorld expression, which simply translates relative values to values in the 3D world, but it makes codes very long, so I must use variables for this:

y=thisComp.activeCamera.toWorld(thisComp.layer("Cam Ctrl").position);

What happens is that we've told it that y is the camera's position converted to the world relative to Cam Ctrl's position. Now, that immediately resolves our problem!!
The only problem is that should we delete the Camera or the Null, we'll get an error. And especially deleting the Null, because then we'd have to revert to the previous expression. Also, that's a lot of code to remember, especially for something we're not likely to use often.

So how can we resolve this? Well, I'm here to help!
 I'm giving out one of the presets from the upcoming Presets Pack: Face Camera!

Face Camera is an animation preset that applies a tweaked version of the above code to the Orientation of the selected layer. It makes the layer it is applied to always face the Active Camera, whether there is a Null involved or not.
Add a Camera, Face Camera takes effect. Add a Null and Parent the Camera, Face Camera immediately adapts to the changes applied. Face Camera will always face the active camera in the timeline. Disable a camera and activate another, Face Camera will switch to that one immediately.
Deleting the Camera or Null will not hang the expression. Face Camera will simply be on standby until a Camera is applied.

To use Face Camera, copy the file to:
Libraries > Documents > Adobe > After Effects CSx > User Presets
C:\Program Files\Adobe\Adobe After Effects CSx\Support Files\Presets

It should be accessible via the Effects & Presets panel.
Drag and drop to a 3D layer to get it to face the active camera.


What do you think? Drop a comment below, or like and comment on the Facebook page


  1. Yeah it s a very clever way to achieve this effect, i think it s actually the best way.  Thank u mister ideas ;-)

  2. I'm glad you like it :-D Have fun with it and feel free to link me to anything you make so I can feature it here :-D

  3. Thanks for sharing this (and the rest of your site), it's cool use of expression to handle complex math. I think in this case you may also have been able to use Layer>Auto Orient... (Towards Camera). ;-)

  4. Hahahaha thanks! Funny enough, I realized that a few weeks after writing this tutorial! :-D

  5. Hey Nice article and nice blog! Keep it up!

  6. Thanks a lot! I definitely will :D