Monday 28 January 2013

From Comp Space to Layer Surface


From Comp Space to Layer Surface

There’s a somewhat obscure layer space transform that
you haven’t looked at yet, namely fromCompToSurface().
This translates a location from the current comp view to
the location on a 3D layer’s surface that lines up with that
point (from the camera’s perspective). When would that
be useful?
Imagine you have a 2D comp-sized layer named Beam, to
which you have applied the Beam Effect. You want a Lens
Flare effect on a 3D layer to line up with the ending point
of the Beam effect on the 2D layer. You can do it by applying
this expression to the Flare Center parameter of the
Lens Flare effect on the 3D layer:
beamPos = thisComp.layer("beam").effect("Beam")
➥("Ending Point");
fromCompToSurface(beamPos)
First, store the location of the ending point of the Beam
effect into the variable beamPos. Now you can take a couple
of short cuts because of the way things are set up. First,
the Ending Point parameter is already represented as a
location in the Beam layer’s space. Second, because the
Beam layer is a comp-sized layer that hasn’t been moved or
scaled, its layer space will correspond exactly to the Camera
view (which is the same as comp space). Therefore, you

can assume that the Ending Point is already represented
in comp space. If the Beam layer were a different size than
the comp, located somewhere other than the comp’s center,
or scaled, you couldn’t get away with this. You would
have to convert the Ending Point from Beam’s layer space
to comp space.
Now all you have to do is translate the beamPos variable
from comp space to the corresponding point of the surface
of the layer with the Lens Flare, which is accomplished
easily with fromCompToSurface().
You’ll look at one more example of layer space transforms
in the big fi nale “Extra Credit” section at the end of the
chapter.

No comments:

Post a Comment