Skip to main content
Participant
February 15, 2021
Answered

Expression linking size of layer to camera's Z position to keep same pixel density

  • February 15, 2021
  • 1 reply
  • 1189 views

Hey everyone,

I've been stuck with an issue here and  I need your advice.
I've got a 3D parallaxed enviroment with a character running in place while the rest of the background is linked to a Null which runs on the X axis. The camera is also linked to a Null and that way I can  control the zoom in's/out. There's also some passive wiggle to the camera's orientation, just to add some life in the whole outcome.

My main issue is that I want a 3D layered text to appear next to my character which in return will keep the same pixel ratio wether the camera zoom's in or out.
I've been thinking if there's some sort of expression that links the Zposition of the camera to the Scale size of the text layer so it can keep it always the same pixel  size.

Correct answer Rick Gerard

Try this:

C = thisComp.activeCamera;
CP = fromWorld(C.toWorld([0,0,0]));
L = thisLayer
LP = fromWorld(L.toWorld(anchorPoint));
d = length(CP, LP);
z = C.zoom;
r = d/z
r * value

Save it as an animation preset. You will use it often.

1 reply

Rick GerardCommunity ExpertCorrect answer
Community Expert
February 16, 2021

Try this:

C = thisComp.activeCamera;
CP = fromWorld(C.toWorld([0,0,0]));
L = thisLayer
LP = fromWorld(L.toWorld(anchorPoint));
d = length(CP, LP);
z = C.zoom;
r = d/z
r * value

Save it as an animation preset. You will use it often.

Alex5E5CAuthor
Participant
February 17, 2021

YES!! Oh, man I absolutely loved it!
There's also some wiggle in the camera's orientation values. Is there a way around that too? (I need to keep the text always straight)