Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions 2 sided layer…my god

  • 2 sided layer…my god

    Posted by Tayler Ursu on February 26, 2014 at 6:18 am

    Hey! When I change the x rotation 180 degrees to flip the circle.. the expression i have doesnt change the color in time. any tips?

    7158_hmmmm.jpg.zip

    try {
    layerCameraVec = comp("Green 2 Color").activeCamera.position - to_world(anchor_point);
    layerCompVec = to_world_vec([0,0,1]);
    a = radians_to_degrees(Math.acos(dot(layerCameraVec,layerCompVec)/length(layerCameraVec)));
    if (a < 90)
    0
    else
    transform.opacity

    }
    catch(err)
    {
    if (toCompVec([0,0,1])[2] > 0)
    transform.opacity
    else
    0
    }

    Darby Edelen replied 12 years, 6 months ago 2 Members · 4 Replies
  • 4 Replies
  • Darby Edelen

    February 26, 2014 at 8:06 am

    [Tayler Ursu] “if (toCompVec([0,0,1])[2] > 0) transform.opacity else 0”

    That doesn’t do what you want?

    It’s not clear what you’re trying to do. I assume you want the layer to be invisible when its back faces the camera, and that’s what the above quoted code should do. Everything in the try{} statement seems superfluous but perhaps you’re trying to do something more. I can’t tell what that would be from the code though, could you provide more detail as to what you’re trying to achieve?

    Darby Edelen

  • Tayler Ursu

    February 26, 2014 at 3:53 pm

    Hey Darby,

    Thanks for the response, sorry if I was unclear! My camera is on an angle as shown in the picture. I have two layers, a grey circle and a green circle. When my camera pans across the plane of dots I need the circle to flip revealing the color. I have all of the circle layers precomposed. My trouble is that the green circle reveals itself at 90 degrees but I need it to reveal itself as soon as you start seeing the underside of the circle!

    My guess is that I will have to create a null object and parent both layers to it. From there move the back circle back in z space. This would just slow me down big time as I have 1000’s of layers.

    ***Forgot to mention. The camera I am using isn’t with the precomposed circle layers. It is in the main composition.. as these circles are used through out the project.

    Thanks for the help man!

  • Darby Edelen

    February 26, 2014 at 9:13 pm

    Delete everything in your “try{}” statement and only keep the code in your catch():

    if (toCompVec([0,0,1])[2] > 0) transform.opacity else 0

    Darby Edelen

  • Darby Edelen

    February 26, 2014 at 9:24 pm

    I see now that you have the layer that should be changing color in a pre-comp. I’d approach this differently in that case.

    In the pre-comp trim the gray layer so that it exists at 0 seconds and ends before 1 second, then place the green layer so that it starts at 1 second.

    Instead of applying an expression to the opacity inside the pre-comp, enable time-remapping on the pre-comp in the main composition and apply this expression to the time-remapping:

    if(toCompVec([0,0,1])[2] > 0) 0 else 1

    You can change the place of the 0 and the 1 if the layers are appearing in the wrong order.

    Darby Edelen

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