Learn how to move layer along the Z axis to add depth to your composition without affecting the proportion of the original image
1. Setup
Start by importing your multi-layered AI or PSD (choose to import as composition, not rasterized footage), or create your 2D artwork directly in AE.
Then turn on for each layer the 3D layer toggle and add a camera to your comp.
2. Expression writing
First thing to notice is, when creating a new camera, is
camera.position[2] = cameraOption.zoom = cameraOption.focusDistance
Any layer positioned at [0,0,0] will be exactly at the same place and will keep the same proportions when looking through the camera.
Distance to Camera
note that the absolute distance between the camera and the object along the Z axis is z + d
- Add an expression on the scale scale property of any of the layer
var d = position[2];
scale * ((d + z) / z)
Note that the first line of code instruct to retrieve the active camera zoom value.
- Copy the expression
- Reveal the scale property of all the layers in 3d space: select the layers and type’s’
- paste the expression
Now when moving a layer along the Z axis, it will look as if nothing happens, but if you select the top view, you can see its actual position. You will still be able to scale up/down any layer.
You might be interested by Paul Tuersley’s Multiplane script that automates this method plus automatically distribute layers along Z axis.
build your own presets collection to speed up your workflow
Click icon below to download the AE preset (rename .key to .zip after download)
another method :
var cam = thisComp.activeCamera;
var d = Math.abs(position[2]-cam.position[2]);
scale * (d/cam.zoom)
LikeLike