ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Layers opacity dependent on each other

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Albert Kowalski
Layers opacity dependent on each other
on Feb 14, 2018 at 2:33:08 pm

Hi!

I was wondering if there's possibility to make mulitple layers dependent on each other. Here's the thing. I have 10 layers and I only one of them should be visible at the time. So when I change one layer's opacity to 100, the rest of the layers should turn 0. Is it possible to


Return to posts index

Andrei Popa
Re: Layers opacity dependent on each other
on Feb 14, 2018 at 2:55:41 pm

One workaround would be to make a null and add a slider. And make the layer that the slider indicates visible, and the rest invisible. Something like this would fix the situation. In my case the layer is called "Controls" and the slider is called "Visible layer". visibleLayer = Math.floor(thisComp.layer("Controls").effect("Visible layer")("Slider"));
if (visibleLayer == index) 100 else 0

The condition for this would be that your layers start at layer 1 and don't have any other layers between them

Andrei
My Envato portfolio.


Return to posts index

Albert Kowalski
Re: Layers opacity dependent on each other
on Feb 14, 2018 at 3:00:37 pm

Thanks! This is pretty good, but not very smooth in my case. My layers contain mouth shapes, and it would be a bit uncomfortable to always check which mouth has which layer number and then adjust the slider. Especially when I need to animate long phrases.


Return to posts index


Steve Sierra
Re: Layers opacity dependent on each other
on Feb 14, 2018 at 5:44:31 pm

Hi,

Expanding on Andrei's technique, you could add a hidden text layer where you change the source text to your mouth shape letter ("a", "o", etc...)
Then, in your mouth shape opacity expressions, add a variable that is the shape's letter.
Then, replace the slider variable in Andrei's expression by the text layer's source text... I can't try it out now, but it should look like this :

var letter = "a";
var text = thisComp.layer("TextLayer").text.sourceText;
if (letter == text) 100 else 0


This way is index free as well !
Hope it helps ;)


Return to posts index

Albert Kowalski
Re: Layers opacity dependent on each other
on Feb 15, 2018 at 11:43:25 am

Thanks Steve. Nice one, but I don't really know how it can speed up my workflow. In your example I would need to keyframe the Source Text which is pretty time consuming. What I need is simple one click solution :)


Return to posts index

Steve Sierra
Re: Layers opacity dependent on each other
on Feb 15, 2018 at 12:31:54 pm

Hi again Albert,

What do you want to animate ?
With my solution, you don't have to animate the opacity properties any more, you just have to keyframe the text layer as you said.

Best regards
;)


Return to posts index


Albert Kowalski
Re: Layers opacity dependent on each other
on Feb 15, 2018 at 1:06:17 pm

It doesn't really matter what I will animate. But it is easier to change the opacity twice (first making one layer visible and second make different layer hidden = two steps with two mouse click'n'drags), than go around and change the text layer which is much more clicks to do. So I'm looking for even faster way to animate = one click only. In my 'opacity' solution it would be like, if I put one opacity to 100%, the rest automatically goes to 0%.


Return to posts index

Steve Sierra
Re: Layers opacity dependent on each other
on Feb 15, 2018 at 2:21:46 pm

Hi again,

Sorry to insist, but I don't see how changing one text layer is more complicated than changing several mouth shape opacity props ?

I'm not sure you understood that you only need one text layer for all the mouth shapes ?

Best regards


Return to posts index

Albert Kowalski
Re: Layers opacity dependent on each other
on Feb 15, 2018 at 3:09:13 pm

Hmm, maybe I didn't understand your idea correctly. From what I see, to change the mouth shape I need to go to the TextLayer, double click in the preview window and type, for example, "A". Then I need to go to the next position, go back to the text layer, delete the previous letter and type a new one. And repeat this action every time I need to change the shape. If this is right I need more time to do that, because it involves using a keyboard everytime I change the shape. When I change the opacity I only move my mouse to change the shape. In the beginning I make toggle hold keyframes in all the layers opacity. Than I just move forward and change the opacity to 100% of one layer (rest stays 0%), then I change different layer opacity to 100% and change the previous one to 0%. So 2 clicks'n'drags to change one shape. In your case I need more moves and also need to use keyboard. Am I right? And ideally I want only 1 click to change the shape.


Return to posts index


Steve Sierra
Re: Layers opacity dependent on each other
on Feb 15, 2018 at 4:11:30 pm

Hi,
I see what you mean now...
In that case, I would recommend using a visual rig.
By moving a layer to a specific zone, you trigger a specific opacity.
That way, you just move your layer to get the mouth shape !

Do you need help on building that ?
Cheers ;)


Return to posts index

Albert Kowalski
Re: Layers opacity dependent on each other
on Feb 15, 2018 at 4:14:28 pm

Wow, sounds great, but honestly I have no idea how to build that :)


Return to posts index

Steve Sierra
Re: Layers opacity dependent on each other
on Feb 15, 2018 at 4:57:21 pm

Here goes :

Let's say you have 4 mouth shapes.
You create a shape or a solid which will be your rig. name it "RIG"
Create 4 text layers, each one with a mouth shape.
Distribute them along the x axis of your comp.
Now we divide your comp in the number of mouth shapes you have (4 in our case so if your comp width is 1920px, than each mouth shape "zone" will be of 480px).
In each mouth shape opacity prop, you have to put an expression like this :

for 1st mouth shape :

var rigXPos = thisComp.layer("RIG").transform.position[0];
if(rigXPos >= 0 && rigXPos < 480){100}else{0};

for the second :

var rigXPos = thisComp.layer("RIG").transform.position[0];
if(rigXPos >= 480 && rigXPos < 960){100}else{0};

for the third :

var rigXPos = thisComp.layer("RIG").transform.position[0];
if(rigXPos >= 960 && rigXPos < 1440){100}else{0};

and the last :

var rigXPos = thisComp.layer("RIG").transform.position[0];
if(rigXPos >= 1440 && rigXPos < 1920){100}else{0};

Make sure your keys are set on hold and you should be good to go !


Cheers ;)


Return to posts index


Albert Kowalski
Re: Layers opacity dependent on each other
on Mar 2, 2018 at 12:08:16 pm

Thank you! I had different stuff to do, but now I will definately check your code :)


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]