Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Is this possible?

  • Posted by John Madison on November 24, 2011 at 4:10 pm

    Hey guys,

    OK, I have a stack of layers spread on the x axis. I have a controller which turns on/off the layers – via opacity. Now, i want to add an effect on the the last visible layer. Obviously, the last visible layer will change depending on the value of the controller, so how do i determine using expressions, which is the last visible layer. If this info can be obtained, then im thinking i can add a simple expression to turn on the effect for that layer. Does this make sense? If so, can it be done?

    John Madison replied 14 years, 3 months ago 2 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    November 24, 2011 at 5:42 pm

    It should be pretty straight forward. I think the expression would have two parts. The first would be to calculate if the expression’s host layer is within the comp boundaries. If not, it’s done (effect not turned on). If it is within the boundaries, then it needs to check the layer to its right (if that’s the direction that layers go off-screen). Whether or not the neighboring layer is within the comp boundaries determines whether or not the effect is turned on. The details depend on the specifics of how you have things set up.

    Dan

  • John Madison

    November 25, 2011 at 12:02 am

    Hey Dan,

    Thanks, but i think there might have been a misunderstanding. There is no motion! The layers are spread across the screen from left to right (no over lapping). Their visibility is determined by a controller which toggles the opacity. So for example, when the slider is 1 the first image is visible and all the other 19 are not and so on. I want to add an effect on the last visible layer in the row. So if 10 are visible then the effect should be on for the 10th layer. If 15 are visible, then on the 15th etc.
    The problem: how do i determine, using expression, which is the last visible layer?

  • Dan Ebberts

    November 25, 2011 at 1:28 am

    Are you controlling the opacity with an expression linked to the slider? If so, what’s the expression?

    Also, what’s the effect? Does it have a parameter that can be used to turn it on and off (like blur amount)?

    Dan

  • John Madison

    November 25, 2011 at 2:32 pm

    Yes I am and here is the expression:

    ctrl = thisComp.layer(“Adjustment Layer 1”).effect(“Slider Control”)(“Slider”)
    if (ctrl >= index-1) 100 else 0

    Yes, the effect can be turned on/off such as the glow effect.

  • Dan Ebberts

    November 25, 2011 at 3:39 pm

    Something like this should work:

    ctrl = thisComp.layer(“Adjustment Layer 1”).effect(“Slider Control”)(“Slider”)
    if (Math.floor(ctrl) == index-1) 100 else 0

    You’ll need to change the last two values to whatever works for the effect property you’re controlling.

    If you need the last layer to have the effect turned on no matter how high the slider goes, you might want to change the last line to something like this:

    if (Math.min(Math.floor(ctrl),thisComp.numLayers-1) == index-1) 100 else 0

    Dan

  • John Madison

    November 25, 2011 at 9:21 pm

    Wow! Dan you’re the man! Thanks. If its not too much trouble, could you explain how it works.

  • Dan Ebberts

    November 25, 2011 at 9:26 pm

    Math.floor() just rounds the slider value down to the nearest whole number. The expression just checks to see if that number matches its own layer index minus one.

    Dan

  • John Madison

    January 26, 2012 at 2:59 pm

    Dan,

    You’ve been a lot of help with my queries, but I’ve had to change the above setup slightly and so need help again with the expression.

    The setup is like this:

    Layer A
    Layer B
    Layer C

    Layer C is the one i want to control using the expression above and in normal circumstances i.e. no layers above it, the expression works like a gem. The problem is that Im duplicating ALL three layers quite a few times and would rather not write out the expression on every duplication of Layer C.

    As you can see, the index of Layer C and its subsequent duplications change every time I duplicate the bunch, so how do i change the expression to take this factor in account? The first Layer C has index-2, Layer C2 is index-5, Layer C3 is index-7 and so on…
    Your help is much appreciated mate!

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