ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Opacity fade in and out with marks

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Marcelo Cabral
Opacity fade in and out with marks
on Mar 12, 2013 at 6:02:57 pm

Hi
I am working in a simple project and I need to make opacity fades in and out but using marks in the layer. First mark for the fade in and next mark for the fade out. Thanks in advance.


Return to posts index

Dan Ebberts
Re: Opacity fade in and out with marks
on Mar 12, 2013 at 6:30:15 pm

Something like this maybe:


fadeTime = .5;
if (marker.numKeys > 1){
t1 = marker.key(1).time;
t2 = marker.key(2).time;
if (time < (t1+t2)/2)
ease(time,t1,t1+fadeTime,0,100)
else
ease(time,t2-fadeTime,t2,100,0);
}else
value


Dan



Return to posts index

Marcelo Cabral
Re: Opacity fade in and out with marks
on Mar 12, 2013 at 7:15:59 pm

Thank you Dan!! it works awesome. That was I was looking for. Best regards.


Return to posts index


Dan Ebberts
Re: Opacity fade in and out with marks
on Mar 12, 2013 at 7:25:09 pm

edit: oops responding to wrong post.

Dan



Return to posts index

Marcelo Cabral
Re: Opacity fade in and out with marks
on Mar 12, 2013 at 7:49:39 pm

Hi Dan, me again.
I have this expression to move in and out of the scene a text layer. It works fine but It would be even better with a ease in and ease out controls. Is this posible? Thanks in advance.

m = 450;
if (marker.numKeys > 0 && time <= marker.key(1).time){
value + [1,0]*(time-inPoint)*m;
}
if (marker.numKeys > 0 && time >= marker.key(1).time){
value + [1,0]*(marker.key(1).time-inPoint)*m + [0,0]*(time-marker.key(1).time)*m;
}
if (marker.numKeys > 1 && time >= marker.key(2).time){
value + [1,0]*(marker.key(1).time-inPoint)*m + [0,0]*(marker.key(2).time-marker.key(1).time)*m + [1,0]*(time-marker.key(2).time)*m;
}


Return to posts index

Dan Ebberts
Re: Opacity fade in and out with marks
on Mar 12, 2013 at 9:30:50 pm

Hmmm... I think to do that the expression needs to be able to calculate the distance traveled over a specific interval, and then use ease(), easeIn(), or easeOut(), as appropriate. The way you have it set up, the expression could calculate the distance of the travel up to the first marker, but there's no fixed distance traveled (or fixed interval) after the second marker--it just keeps going. Maybe with 3 markers...

Dan



Return to posts index


Mitch Mann
Re: Opacity fade in and out with marks
on Mar 12, 2013 at 8:53:30 pm

Cool, I didn't know you could do Eval's in expressions, I'm going to try that. Thanks Dan!


Return to posts index

JuanLuis Vich
Re: Opacity fade in and out with marks
on May 18, 2017 at 5:32:46 pm

hi!
on your expression:


fadeTime = .5;
if (marker.numKeys > 1){
t1 = marker.key(1).time;
t2 = marker.key(2).time;
if (time < (t1+t2)/2)
ease(time,t1,t1+fadeTime,0,100)
else
ease(time,t2-fadeTime,t2,100,0);
}else
value


what if we add another "in" marker in the layer later in the timeline?
how it could be modified to have it fading in again? (so basically each time it reaches the "in" it fades in and "out" it fades out, not only the first time

thanks!


Return to posts index

Dan Ebberts
Re: Opacity fade in and out with marks
on May 18, 2017 at 5:58:56 pm

Something like this might work:


fadeTime = .5;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (time < marker.key(n).time) n--;
if (n > 0){
t0 = marker.key(n).time;
if (n%2)
ease(time,t0,t0+fadeTime,0,100)
else
ease(time,t0,t0+fadeTime,100,0);
}else{
0
}
}else
value



Dan



Return to posts index


JuanLuis Vich
Re: Opacity fade in and out with marks
on May 18, 2017 at 7:17:45 pm

awesome!!!

this way every marker will trigger the in and out fading, right? I don't know if it is possible to make it work only if the comment "in" or "out" appears? to prevent any unwanted in/out, I mean...


Return to posts index

Dan Ebberts
Re: Opacity fade in and out with marks
on May 18, 2017 at 7:50:45 pm

That's trickier, especially if it's possible that the expression could run into a marker that doesn't have "in" or "out". It would have to loop back through previous markers to figure out what state it should be in currently.

Dan



Return to posts index

JuanLuis Vich
Re: Opacity fade in and out with marks
on May 18, 2017 at 10:28:24 pm

oh! I didn't know it could be so tricky! nevermind, the last setup you wrote is super handy too, infinite thanks!


Return to posts index


Marcelo Cabral
Re: Opacity fade in and out with marks
on May 19, 2017 at 11:48:42 am

Dan, thank you so much for open our eyes and show us how easy could be working with expressions to make our work so easy and moreover for your time and patient. Awesome, you rock man!!!


Return to posts index

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