Activity › Forums › Adobe After Effects Expressions › Change blur value up and down again (like one sine wave) on every layer marker
-
Change blur value up and down again (like one sine wave) on every layer marker
Posted by Eva Lepik on July 18, 2017 at 1:48 pmHey,
I am trying to create an expression for :
On every layer marker named “H” blur value would ease from 0 up to 50 and ease down to 0 again, all this let’s say during 30 frames.
There will be several markers named H. It should also work if there are no markers on the layer.I tried using Math.sin with interpolation, but it created continuous waves, so probably it was a wrong direction.
I also tried adding 2 interpolations in a row but that worked strangely and caused the value to jump to 50.Could anyone point me a right direction for this?
Thanks in advance for any help!Regards,
EvaDan Ebberts replied 8 years, 9 months ago 2 Members · 7 Replies -
7 Replies
-
Dan Ebberts
July 18, 2017 at 4:37 pm>It should also work if there are no markers on the layer.
What should it do in that case?
Dan
-
Eva Lepik
July 18, 2017 at 7:33 pmHi Dan,
Yes, I forgot to tell that – when there are no layer markers, it should keep the blur value at 0.
Based on some expression written here by you, Dan, I changed it a bit and got this – and it works now ☺But how could I change it so that it looks to layer markers of a range of layers (named TR1, TR2, TR3, etc.), not to the layer markers of the same layer where the expression is?
If that would be possible, then I would further wish
– to link start time and end time of interpolation to slider which is on the layer which marker at certain time is calculated. Each layer will only have 1 marker (or no markers at all).It sounds really complicated (at least for me and now), but I have seen that studying parts of your expressions here can help a long way. I am thinking many if else conditions but is there perhaps a shorter way to do this?
Thanks for your answer,
EvamaxY = 50;
minY = 0;
n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time >= time){
n++;
if (n > marker.numKeys) n = 0;
}
}
if (n > 0){
if (marker.key(n).comment == "H")
Math.min (ease(time,marker.key(n).time,marker.key(n).time+framesToTime(30/2),minY,maxY),
ease(time,marker.key(n).time+framesToTime(30/2),marker.key(n).time+framesToTime(30),maxY,minY))
}else
{
0
} -
Dan Ebberts
July 18, 2017 at 8:02 pmYou could try something like this:
d = framesToTime(30);
tMax = -99999;
for (i = 1; i <= thisComp.numLayers; i++){
if (i == index) continue;
L = thisComp.layer(i);
if (L.name.substr(0,2) != "TR") continue;
if (L.marker.numKeys == 0) continue;
if (L.marker.key(1).comment != "H") continue;
if (L.marker.key(1).time > time) continue;
tMax = Math.max(L.marker.key(1).time,tMax);
}
if (tMax > 0){
t = time - tMax;
if (t < d/2)
ease(t,0,d/2,0,50)
else
ease(t,d/2,d,50,0);
}else{
0
}
It it triggers at markers with an “H” comment only layers with names beginning with “TR”. Note that it will re-trigger if markers are closer together than 30 frames.
>to link start time and end time of interpolation to slider which is on the layer which marker at certain time is calculated.
I’m not sure what you meant by that, so I didn’t include it.
Dan
-
Eva Lepik
July 18, 2017 at 10:00 pmWow!
This works like a charm.
Thank you so much. I will now study this to try to understand every bit of it.With linking interpolation duration (which now is 30 frames every time) to slider,
I meant to make it possible to vary duration for every interpolation time separately.
For example there is a slider on TR1 which has value 20, slider on TR2 has value 30, slider on TR3 has value of 10 etc.Thanks again,
Eva -
Dan Ebberts
July 18, 2017 at 11:23 pmIncluding the sliders could look like this:
d = framesToTime(30);
tMax = -99999;
for (i = 1; i <= thisComp.numLayers; i++){
if (i == index) continue;
L = thisComp.layer(i);
if (L.name.substr(0,2) != "TR") continue;
if (L.marker.numKeys == 0) continue;
if (L.marker.key(1).comment != "H") continue;
if (L.marker.key(1).time > time) continue;
if (L.marker.key(1).time > tMax){
tMax = L.marker.key(1).time;
d = framesToTime(L.effect("Slider Control")("Slider"));
}
}
if (tMax > 0){
t = time - tMax;
if (t < d/2)
ease(t,0,d/2,0,50)
else
ease(t,d/2,d,50,0);
}else{
0
}
Dan
-
Eva Lepik
July 25, 2017 at 7:22 amHi Dan,
The last version you gave me, works also with the sliders, many thanks!
I get most of the lines, but I was wondering about the tMax value you state in the beginning (-99999), could you explain why it needs to be that?
I have previously used only quite simple expressions and don’t yet understand many elements, therefore the question.With regards,
Eva -
Dan Ebberts
July 25, 2017 at 3:54 pmThat’s just an arbitrary negative number to make sure that the first time this line is executed:
if (L.marker.key(1).time > tMax){
it will evaluate true and execute the if clause.
Dan
Reply to this Discussion! Login or Sign Up