Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Linking 3D rotation to opacity

  • Linking 3D rotation to opacity

    Posted by Lauren Roundy on November 18, 2009 at 6:00 pm

    I have a composition that is set up similar to the video here:

    link

    Basically the individual images are all spaced evenly around a null object in the center of the comp, and then they are all parented to that null object so that as the null object is rotated in 3D space, the individual images rotate around with it.

    What I want is for the images to only be full opaque when they are perfectly facing the camera. To make this easier, I will only be rotating this images on the Y axis, and I won’t be messing with the null’s x or z axis.

    How can I set it up so that as the images are facing the camera (so, for example, the null is set it 0 degrees on the y axis, and image 1 is facing the camera) that they are fully opaque, but then, as the null rotates to say -35 degrees, image one fades down and the next image (image 2) is now facing the camera and fully opaque?

    Does that make sense. I would like them to fade and even blur if possible when they aren’t directly facing the camera. If the null rotates to +35 degrees, I would want the same thing to happen (image 1 fades away and the next image in the sequence fades in)

    Please help! Thanks!

    Yono Yo replied 15 years, 11 months ago 3 Members · 12 Replies
  • 12 Replies
  • Dan Ebberts

    November 18, 2009 at 7:21 pm

    Give this a try:

    fadeAngle = 35;

    v1 = toWorldVec([0,0,1]);
    try{
    C = thisComp.activeCamera;
    v2 = C.toWorldVec([0,0,1]);
    }catch (err){
    v2 = [0,0,1];
    }
    angle = radiansToDegrees(Math.acos(dot(v1,v2)));
    ease(angle,0,fadeAngle,100,0)

    Dan

  • Lauren Roundy

    November 18, 2009 at 7:38 pm

    Thanks, but not sure exactly how to apply this. Do I just apply it to the opacity of my individual layer?

    It gave me an error when I tried, said “invalid numeric result (divide by zero?)” or something.

  • Dan Ebberts

    November 18, 2009 at 8:00 pm

    Ah, OK. Try this one (apply it to Opacity). It assumes you have a camera named “Camera 1”.

    fadeAngle = 35;
    v = toCompVec([0,0,1]);
    d = length(toWorld(anchorPoint),thisComp.layer(“Camera 1”).toWorld([0,0,0]));
    c = v[2]/d;
    ease(c,Math.cos(degreesToRadians(fadeAngle)),1.0,0,100)

    Dan

  • Lauren Roundy

    November 18, 2009 at 8:12 pm

    Excellent… This worked great! Thank you so much.

    A couple more questions, if you’re willing… How can I get the opacity transition to happen or ease a bit more gradually (so it’s not so harsh)? Also, how difficult would it be to apply this same idea to scale and bluriness of the fast blur effect?

    I’m sure I could figure these others out with some tweaking, but I just don’t understand exactly what this expression is doing (what does toCompVec or Math.cos(degreesTRadians),1.0,0,100 mean?

    Thanks!

  • Dan Ebberts

    November 18, 2009 at 8:31 pm

    To make it less abrupt, I guess you could increase the fade angle, and/or play around with changing ease() to easeIn() or easeOut() or even linear().

    Here’s a version that should work with any property, you just need to edit the first two lines:

    startVal = 0;
    endVal = 100;
    fadeAngle = 60;

    v = toCompVec([0,0,1]);
    d = length(toWorld(anchorPoint),thisComp.layer(“Camera 1”).toWorld([0,0,0]));
    c = v[2]/d;
    ease(c,Math.cos(degreesToRadians(fadeAngle)),1.0,startVal,endVal)

    For scale you would change the first two lines to something like this:

    startVal = [100,100];
    endVal = [150,150];

    For blur, something like this:

    startVal = 15;
    endVal = 0;

    Dan

  • Lauren Roundy

    November 18, 2009 at 8:35 pm

    Thanks. This version helps me understand much better what to adjust and what not to.

    Again, THANKS!

  • Yono Yo

    May 31, 2010 at 5:25 pm

    Hi,

    I’m trying to do quite the same thing : I created a cube and placed logos on each face of it.
    The cube is rotating around its x and y axis. I want the opacity of each logos to be full when the camera faces them and to be null the rest of the time.

  • Dan Ebberts

    May 31, 2010 at 5:35 pm

    You’re probably looking for something like this:

    toCompVec([0, 0, 1])[2] > 0 ? value : 0

    Dan

  • Yono Yo

    May 31, 2010 at 6:08 pm

    Yes actually, but I’d like the logo to disapear slightly before that it does with this expression, otherwise it can be seen trought the cube, because of the perspective.

    I thought replacing the 0 of your expression by 0,1 for instance would do the job :
    if ( toCompVec([0,0,1])[2] > 0,1 ) 100 else 0

    But that wouldn’t work…

    Thanx for the quick response by the way !

  • Yono Yo

    May 31, 2010 at 6:21 pm

    shame on me I put a “,” instead of a “.”

    Anyway I don’t understand this expression : does it make a projection of the world’s z vector on the comp z vector ? So the resulting value would evolve between -1 and 1 ?

Page 1 of 2

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