Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions link stroke width to camera position

  • link stroke width to camera position

    Posted by Todd Morgan on May 9, 2011 at 4:55 pm

    Looking for help with linking stroke width to camera position z depth. Basically, looking to keep all my outline strokes the same size, even when object fly toward camera. Currently, when object flies towards and past camera, stroke size increases (as it should) but I need to keep all strokes the same for cartoon effect.

    Thanks in advance for all responses!

    Dan Ebberts replied 11 years, 8 months ago 5 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    May 9, 2011 at 8:02 pm

    Something like this should help:

    nominalDist = 400;

    d = length (thisComp.layer(“Camera 1”).toWorld([0,0,0]),toWorld(anchorPoint));
    value*(d/nominalDist)

    Set nominalDist to the distance where you want the stroke width to be the value you have it set to.

    Dan

  • Todd Morgan

    May 10, 2011 at 12:11 pm

    Works like a charm!! Thanks!!

  • Mike Theodoran

    November 19, 2012 at 3:58 pm

    I am trying to achieve the same effect with the stroke linked to the camera to keep the stroke width consistent.

    On what layer and what attribute do I put the expression on?

    Thanks for any assistance you can offer.

    Mike

  • Dan Ebberts

    November 19, 2012 at 6:00 pm

    You would apply that expression to the stroke width property.

    Dan

  • Mike Theodoran

    November 20, 2012 at 6:27 pm

    Thanks for your help Dan.

  • Ze’ev Gilad

    September 10, 2014 at 3:44 pm

    I said it before, I’ll say it again:
    Dan, you are the MAN!

  • Brien Hopkins

    November 24, 2014 at 4:48 pm

    Hi Dan,

    I came across this thread today, and your expression works like a charm. I’m curious if there’s a way to achieve a similar effect, when there is no camera in the scene. If the line itself moves in Z space (not the camera) could the stroke remain constant?

    Thanks,
    Brien

  • Dan Ebberts

    November 24, 2014 at 9:52 pm

    You could try using something like this to simulate a camera:

    nominalDist = 400;

    w = thisComp.width * thisComp.pixelAspect;
    z = (w/2)/Math.tan(degreesToRadians(19.8));
    C = [thisComp.width/2,thisComp.height/2,-z];
    d = length (C,toWorld(anchorPoint));
    value*(d/nominalDist)
    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy