Production

Making 3D Effects Behave Like 3D

Making older 3D plug-ins follow 3D cameras in After Effects.

Expressions can make “fake” 3D plug-ins such as CC Sphere track After Effects’ 3D cameras.

After Effects is, at heart, a 2D program: All layers have no thickness. You can arrange them in 3D space, illuminate them with 3D lights, and fly around them with 3D cameras, but if you view the layers on-edge, you will still see that they have no thickness.

A number of clever plug-in effects work around this by taking an image and the camera, rendering what it would look like if it actually had depth (such as extruded text, or an image wrapped around a sphere), and then render the result back to a flat 2D layer. Although a great stride trick, there are some limitations.

The biggest one is that – counter to what you might expect – layers which use these fake 3D plug-ins must be tagged as 2D layers, rather than 3D. This is to prevent a camera’s movements from being calculated twice: once by the plug-in, and once by After Effects as it figures out the relationship between the camera and the layer. Some of these plug-ins also make you choose which one camera and one light they react to, rather than reacting to all lights or automatically switching to whatever the current active camera may be.

When a 3D camera moves around a layer with a fake 3D effect applied (such as this example, where the camera has been moved to the left and below the layer), you can tell it’s really just a flat image (above left). However, you can add expressions to make this layer face the camera (above), and for the effect to counter-rotate so that the image rendered by the effect appears to face in the correct direction (left).

This causes some problems in the interactions between layers. For example, 2D layers cannot cast natural shadows onto 3D layers and vice-versa. This scheme also throws off some of the depth sorting that decides which layer is in front of another, as 2D layers don’t have a Z position in space. Instead, 2D layers render between 3D layers that appear above or below them in the Timeline window. These 2D layers act as rendering “breaks” in that 3D layers above them in the Timeline stack cannot cast shadows or be positioned behind 3D layers that are stacked below the intruding 2D layer, regardless of their relative positions in space.

Don’t get us wrong – the ability to intermingle 2D and 3D layers in After Effects is useful and cool – but it can make managing fake 3D effects a pain.

Fortunately, there is a workaround that allows you to apply a fake 3D effect to a 3D – rather than 2D – layer, and still track the After Effects camera. This means it can interact properly with other 3D layers. This workaround only requires that these plug-ins give you access to their X, Y, and Z rotations in the Timeline window (which most do), and for you to apply a few relatively simple Expressions to control their rotations. This fix can be applied to both old plug-ins which are unaware of After Effects’ cameras, or as an alternative for new ones which otherwise would have the ability to track a camera all by themselves.

next page: the expressions required to pull this off


Orient and Rotate

Explaining the problem took far longer than it will to explain the cure. First, you need to make the layer rotate to always face the camera. Second, you need to make the plug-in counter-rotate its render by the same amount, to make the rendered image appear stationary in 3D space as the camera moves around it.

To try this for yourself, create a layer that takes advantage of one of these 3D plug-ins such as Simulation > Shatter or Perspective > CC Sphere. Turn on the 3D Layer switch for this layer. Then add a Layer > New > Camera to your composition, and animate it to fly around or by your layer. As the camera moves around, you will notice some perspective distortion in your image as you view it on edge.

Reveal the Rotation and Orientation properties for your layer. Select the Orientation property and use Animation > Add Expression; then type in the following expression:

lookAt(thisComp.activeCamera.position, position)

This one-line expression instructs the layer to auto-orient itself so that it will always “look at” whatever the active camera is in this composition. You should notice your layer is now viewed without perspective distortion. As your camera moves, notice how the Orientation parameters for the layer change to keep it facing the camera.
Next, reveal the X, Y, and Z Rotation parameters for the 3D effect you have applied to your layer. Enable Expressions for these three parameters, and give them the following one-line expressions, respectively:

360 – orientation[0]
360 – orientation[1]
360 – orientation[2]

These expressions counteract the orientation changes caused by the “look at” expression you applied to the overall layer. The numbers in brackets indicate which axis of Orientation is being compensated for: [0] is the X axis, [1] is the Y axis, and [2] is the Z axis. After applying these expressions, as your camera moves around the object, the plug-in will compensate and make the layer always appear to point in its original direction in 3D space.

In some cases, these three expressions might need tweaking. For example, with CC Sphere, C Particle World, and Zaxwerks Invigorator, the expression attached to the effect’s X Rotation (called “Camera Tumble Up/Down” in previous versions of Invigorator) should just be orientation[0] without the need to subtract it from 360. Also, you will probably need to disable or delete the Z Rotation expression for most effects – they just don’t look natural with it turned on, even though mathematically it should be correct. Effects which do benefit from this Z Rotation expression include Boris Cube and Forge Freeform.

These expressions give you freedom to animate either the layer or the camera as you wish. The only problems we’ve encountered so far is when you fly the camera extremely close to and past the layer with the effect applied, we’ve occasionally seen a form of whiplash where the layer rotates back into view – but this is easily cured by trimming the layer’s out point to end once the camera has flown by. You also still have the normal problem where some effects are clipped by the boundaries of the layer itself; this is cured by applying the effect to a precomp which has extra pixels around the edges of the image you want to treat.

CC Particle World is an example of an effect that can produce unsatisfactory results; its “floor grid” appears to over-rotate in the Y axis. We wouldn’t be surprised if other little discrepancies turned up with other effects as well. Effects that have been updated to directly track the camera also can take advantage of other parameters, such as reading the camera’s Angle of View. Overall, though, we think this workaround is a nice solution to better integrating fake 3D effects.

Further Fakes

Several years ago, we wrote a book – After Effects in Production – which used this trick in one of the tutorials. The book also contains an additional trick that we described in another column where an effect’s internal “light” can also be made to follow the position of an After Effects camera or light. This second trick even works with effects such as Bevel Alpha and Texturize, retrofitting them to react to 3D space.

The content contained in our books, videos, blogs, and articles for other sites are all copyright Crish Design, except where otherwise attributed.


Support ProVideo Coalition
Shop with Filmtools Logo

Share Our Article

Chris & Trish Meyer founded Crish Design (formerly known as CyberMotion) in the very earliest days of the desktop motion graphics industry. Their design and animation work has appeared on shows and promos for CBS,…

Leave a Reply

avatar
  Subscribe  
Notify of