Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Dynamic lensflare problem

  • Dynamic lensflare problem

    Posted by Rune Månsson on July 9, 2009 at 1:11 pm

    Hi Guys

    I trying to create an expression that dynamicly changes the brightness of a lensflare as it passes by the camera. The lensflare is attached, via an expression, to a 3D null object. The expression belov yields the desired result, but if the null object is directly behind the camera, the lensflare is rendered, which is not desired.

    The lensflare layer is a 2D layer and gets its information from the null object “Child 2” and the “Camera 1”

    This is what was added in the lensflare brightness property:
    it works, but doesn’t shut the lensflare off when behind the camera.

    cam = thisComp.layer(“Camera 1”);
    camP = cam.toWorld(cam.transform.position);

    c = thisComp.layer(“Child 2”);
    cP= c.toWorld(c.transform.position);

    vec = cP-camP;

    dist= length( vec );

    dist = 100 – (dist*4)/100; //The adding and deviding was to creat a exponential scale in brightness.

    This is what was added in the lensflare position property:

    c=thisComp.layer(“Child 2”);
    p=c.toComp(c.anchorPoint);

    The thought was that the camera would be animated, so I can’t just use the Z-axis as a referencepoint. I need a way to detect if the Null object “Child 2” is behind the camera, no matter what way the camera is pointing and where it positioned.

    You guys have any suggestion?

    Dan Ebberts replied 16 years, 10 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    July 9, 2009 at 1:28 pm

    Try this:

    cam = thisComp.activeCamera;
    camP = cam.toWorld([0,0,0]);

    c = thisComp.layer(“Child 2”);
    cP= c.toWorld(c.transform.anchorPoint);

    vec = cP-camP;

    dist= length( vec );

    if (cam.fromWorldVec(vec)[2] < 0 ){ 0 }else{ 100 - (dist*4)/100; } Dan

  • Rune Månsson

    July 9, 2009 at 1:34 pm

    Dan you truely are amasing!!

    Thank you, you saved the last of my hair from being pulled! It worked. Thanks 🙂

  • Rune Månsson

    July 9, 2009 at 1:45 pm

    Hey Dan

    howcome I have to use the anchorPoint? Why doesn’t the position attribute work? They have the same value, don’t they?

  • Dan Ebberts

    July 9, 2009 at 3:38 pm

    The anchor point is always represented in the layer’s space (relative to the layer’s upper left corner), but the position is relative to world space, or (if the layer has a parent) relative to the parent’s upper left corner. The toWorld() and toComp() layer space transforms expect a parameter that’s in the layer’s space, which is usually the anchor point.

    Dan

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