Groups > Multimedia > Adobe After Effects expressions > Re: Keep layer scale visually constant while




Keep layer scale visually constant while moving through 3D
space

Keep layer scale visually constant while moving through 3D space
Sat, 13 Oct 2007 12:53:08 -070
I'm matching some 2D elements into a 3D rendered scene using 3D camera data
imported from Cinema 4D.

I have an AE 2D layer matched to a 3D object in my Quicktime render. Of course,
as my 3D camera moves through the scene, the AE layer grows in size at it
approaches.

Post Reply
Re: Keep layer scale visually constant while
Sat, 13 Oct 2007 14:41:16 -070
I'm a little confused by your post. If you move a camera on a 2D layer it always
stays the same size and in the same position. If, however, what you really want
to do is to keep a 3D layer exactly the same size in the frame as you move the
camera you can try the following expression:

      zoom = thisComp.layer("Camera 1").cameraOption.zoom;
      distance = length(position, thisComp.layer("Camera
1").position);

      sf = distance/zoom;
      s = sf * value[0];
      [s, s, value[2]];

This expression allows you to uniformly scale the layer to any size you want and
then maintain that size no matter what the distance from the camera. If you want
to fill the frame make sure the layer is set to Auto Orient towards the camera.
If you need different scale values for X and Y then you would modify the s value
to something like sx = sf * value[0]; and sy = sf * value[1]; The s would then
be replaced with sx and sy.

Post Reply
Re: Keep layer scale visually constant while
Sat, 13 Oct 2007 14:55:05 -070
Hi Rick! Thanks for your quick reply. Sorry if I wasn't clear. My camera is
moving in 3D space and all my AE layers are in 3D space too. It looks like your
solution nailed it.

I substituted an expression slider control for "value[0]" so I can
select and animate a scale value. Is that correct?

Post Reply
Re: Keep layer scale visually constant while
Sat, 13 Oct 2007 14:58:28 -070
My solution does not require a slider. The value statements allow you to change
the scale and set keyframes, but if you want to use a slider that's just fine.

I'm not sure why auto orient towards camera turned the layer, it doesn't for
me.

Glad this worked for you. All I did was take the ratio between the zoom value
and the distance between the camera and the layer and multiply that ratio by the
scale. Simple algebra.

Post Reply
Re: Keep layer scale visually constant while
Sat, 13 Oct 2007 15:26:11 -070
I just figured out why your layers rotated... Should have jumped right out at
me. POI... point of interest. You can fix that by adding a look at expression to
the layer's orientation property. This will keep the layer square to the camera
at all times no matter what the POI.... It kind of results in an odd appearance
but it may be useful for something.

      fromPoint = thisComp.layer("Camera
1").transform.pointOfInterest;
      atPoint = thisComp.layer("Camera 1").transform.position;

      lookAt(fromPoint, atPoint);

 Let me know if there's anything else.

Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact