Copy link to clipboard
Copied
Hi there,
I have this sampleImage expression on a shape layer opacity property that looks at the Alpha channel of a "Master Matte"layer beneath it and adjusts its Opacity to either 0 or 100 value.
Is there a way to have the Opacity fade out from 100 to 0 for a certain amount of time when the sample switches from 0 to 1 alpha? At the moment it changes immediately.
Thank you
lyrsrc=thisComp.layer("Master Matte");
pos1 = thisProperty.propertyGroup(1)(2);
pos2 = thisProperty.propertyGroup(4).transform.position;
point = pos1+pos2;
tst = lyrSrc.sampleImage(point, radius = [2, 2], postEffect = true, t = time)[3];
if (tst > .5){
0;
}
else{
100;
}
Copy link to clipboard
Copied
Sure. Just add the necessary temporal logic and a linear() or whatever interpolator, also necessitationg a while() loop to constantly force the evaluation, accumulate the values and figure out the start condition.
Mylenium
Copy link to clipboard
Copied
Thank you so much for the reply.
My knowledge of expressions is still pretty basic but I'd like to learn more. I'm familiar with the linear interpolation but I'm a little stumped by the way in which to use the while() function and what you mean by temporal logic?
Is there a chance you could break that down a bit more?
Copy link to clipboard
Copied
You run the whole thing in a while loop because AE has no way of rembering variables' values, hence the whole loop needs to be iterated for every frame to correctly accumulate results. just throwing out some basics pseudo-code structure here:
frame=0;
while (time < thisComp.duration)
if (tst > 0.5)
{opa=0;
frame ++;
continue}
else
{opa=100;
break}
Thze accululate value for frame could then be fed into a secondary calculation as the actual event time from which you simply go backwards by subtracting the duration of your fade. Finally you feed it into a linear()
linear(time,startTime,endTime,0,100);
Again, this is just pseudo-code that needs to be fleshed out and tested. I suggest you study the relevant examples like the audio trigger expressions at http://www.motionscript.com/ to get a feel for how this stuff works.
Mylenium
Copy link to clipboard
Copied
Thank you @Mylenium
That does make more sense now, and I'll check out the motionscript page,
Much appreciated!
Chris