Remi Monedi
Forum Replies Created
-
This works great!
Thanks for giving me the “no Javascript engine” version since I work on an older version of AE. -
Hi Andrei,
Thank you for the answer!
I tried to give your expression a shot in AE but I have several error messages :
– first “Math.random()” is not a function. I replaced them by simply “random()”
– “exceptions.indexOf” is undefined and since I’m not sure what this line is for I don’t know how to fix it. Any idea? -
Hi Alex,
The original expression already has the toWorld function, here is the expression :
decay = 5;
freq = 3;
if (decay == 0) decay = 0.1;
if (freq == 0) freq = 0.1;
delay = freq/decay;
weight = 1/decay/10;
frameDur = thisComp.frameDuration;
function worldVelocity(TIME) {
worldVelocityX = (thisLayer.toWorld(thisLayer.anchorPoint,TIME)[0]-thisLayer.toWorld(thisLayer.anchorPoint,TIME-.01)[0])*100;
worldVelocityY = (thisLayer.toWorld(thisLayer.anchorPoint,TIME)[1]-thisLayer.toWorld(thisLayer.anchorPoint,TIME-.01)[1])*100;
return [worldVelocityX,worldVelocityY];
}
function worldSpeed(TIME) {
return length(worldVelocity(TIME));
}
timeStart = 0;
timeRestart = 0;
stop = false;
stopped = false;
for (i=timeToFrames(time);i>=0;i--) {
var t = framesToTime(i);
var tNext = t-frameDur;
if (worldSpeed(t) == 0 ) {
if (timeRestart == 0) timeRestart = t;
if (worldSpeed(tNext) !=0 ) {
timeStart = tNext;
break;
}
}
}
TIME = time-timeStart;
frameRestart = timeToFrames( time-timeRestart);
w = value
if ( frameRestart <= delay)
w = value - worldVelocity(time)*weight*(frameRestart/delay);
else
w = value - worldVelocity(time)*weight;
if (worldSpeed(time) == 0) {
spring = worldVelocity(timeStart) * ( .15/freq * Math.sin(freq * TIME * 2 * Math.PI) / Math.exp( TIME * decay ) );
w + spring;
}else{ w; }And here is the same expression with my changes in bold :
decay = 5;
freq = 3;
if (decay == 0) decay = 0.1;
if (freq == 0) freq = 0.1;
delay = freq/decay;
weight = 1/decay/10;
frameDur = thisComp.frameDuration;
function worldVelocity(TIME) {
worldVelocityX = (thisComp.layer("A").toWorld(thisComp.layer("A").position,TIME)[0]-thisComp.layer("A").toWorld(thisComp.layer("A").position,TIME-.01)[0])*100;
worldVelocityY = (thisComp.layer("A").toWorld(thisComp.layer("A").position,TIME)[1]-thisComp.layer("A").toWorld(thisComp.layer("A").position,TIME-.01)[1])*100;
return [worldVelocityX,worldVelocityY];
}
function worldSpeed(TIME) {
return length(worldVelocity(TIME));
}
timeStart = 0;
timeRestart = 0;
stop = false;
stopped = false;
for (i=timeToFrames(time);i>=0;i--) {
var t = framesToTime(i);
var tNext = t-frameDur;
if (worldSpeed(t) == 0 ) {
if (timeRestart == 0) timeRestart = t;
if (worldSpeed(tNext) !=0 ) {
timeStart = tNext;
break;
}
}
}
TIME = time-timeStart;
frameRestart = timeToFrames( time-timeRestart);
w = value
if ( frameRestart <= delay)
w = value - worldVelocity(time)*weight*(frameRestart/delay);
else
w = value - worldVelocity(time)*weight;
if (worldSpeed(time) == 0) {
spring = worldVelocity(timeStart) * ( .15/freq * Math.sin(freq * TIME * 2 * Math.PI) / Math.exp( TIME * decay ) );
w + spring + thisComp.layer("A").transform.position;
}else{ w + thisComp.layer("A").transform.position; } -
Hi Alex!
I only use this expression with copy/paste, not using a script and it works fine (without me trying to modify it for 2D Point problem). But you’re right, it comes from an old version of the script Duik.
So you think that this expression uses function only described in the script file or something like that?
I didn’t think of this because the expression as itself is working without the use of the script. -
Remi Monedi
February 28, 2020 at 4:43 pm in reply to: OVERSHOOT expression only based on Velocity – NOT keyframesOk, I find a way to adapt this expression to my need. I wasn’t familiar with the .toWorld function.
I replaced the 2 lines I was talking earlier by these 2 and it works fine.worldVelocityX = (thisComp.layer(“A”).toWorld(thisComp.layer(“A”).position,TIME)[0]-thisComp.layer(“A”).toWorld(thisComp.layer(“A”).position,TIME-.01)[0])*100;
worldVelocityY = (thisComp.layer(“A”).toWorld(thisComp.layer(“A”).position,TIME)[1]-thisComp.layer(“A”).toWorld(thisComp.layer(“A”).position,TIME-.01)[1])*100;Now, no matter how the position of a layer “A” is animated, the position of the layer “B” will follow it with an “overshoot” trajectory. Yay!
But clearly, I don’t understand how it works. And I think this expression is only for 2D position parameter. I don’t think it could apply for Rotation or scale (there is length function on line 14). Where the previous expression from Dan was simpler and shorter even if I missed some elements to make it perfectly automated.
SO, I’m still wondering if I can “automate” the overshoot expression from Dan, OR if this long expression from Duik is better for what I want.
Any thoughts?decay = 5;
freq = 3;
if (decay == 0) decay = 0.1;
if (freq == 0) freq = 0.1;
delay = freq/decay;
weight = 1/decay/10;
frameDur = thisComp.frameDuration;
function worldVelocity(TIME) {
worldVelocityX = (thisComp.layer("A").toWorld(thisComp.layer("A").position,TIME)[0]-thisComp.layer("A").toWorld(thisComp.layer("A").position,TIME-.01)[0])*100;
worldVelocityY = (thisComp.layer("A").toWorld(thisComp.layer("A").position,TIME)[1]-thisComp.layer("A").toWorld(thisComp.layer("A").position,TIME-.01)[1])*100;
return [worldVelocityX,worldVelocityY];
}
function worldSpeed(TIME) {
return length(worldVelocity(TIME));
}
timeStart = 0;
timeRestart = 0;
stop = false;
stopped = false;
for (i=timeToFrames(time);i>=0;i--) {
var t = framesToTime(i);
var tNext = t-frameDur;
if (worldSpeed(t) == 0 ) {
if (timeRestart == 0) timeRestart = t;
if (worldSpeed(tNext) !=0 ) {
timeStart = tNext;
break;
}
}
}
TIME = time-timeStart;
frameRestart = timeToFrames( time-timeRestart);
w = value
if ( frameRestart <= delay)
w = value - worldVelocity(time)*weight*(frameRestart/delay);
else
w = value - worldVelocity(time)*weight;
if (worldSpeed(time) == 0) {
spring = worldVelocity(timeStart) * ( .15/freq * Math.sin(freq * TIME * 2 * Math.PI) / Math.exp( TIME * decay ) );
w + spring + thisComp.layer("A").transform.position;
}else{ w + thisComp.layer("A").transform.position; }
-
Remi Monedi
February 28, 2020 at 1:17 pm in reply to: OVERSHOOT expression only based on Velocity – NOT keyframesI found this expression used in Duik from Rainboxprod : instead of using keyframes it uses the anchorpoint Position of the target layer which is parented to another one to overshoot its position.BUT it only works for Position and Anchorpoint.
I tried to modify this expression to fit my needs :
Instead of having a target layer “B” parented to another layer “A” and the position of “B” being “overshot” by the movement of “A”, I want to have any property (position, scale, rotation, …) of “B” linked to the same properties of “A” and being overshot as the properties of “A” change.
But without success…I think the key is somewhere in these lines of code :
worldVelocityX = (thisLayer.toWorld(thisLayer.anchorPoint,TIME)[0]-thisLayer.toWorld(thisLayer.anchorPoint,TIME-.01)[0])*100;
worldVelocityY = (thisLayer.toWorld(thisLayer.anchorPoint,TIME)[1]-thisLayer.toWorld(thisLayer.anchorPoint,TIME-.01)[1])*100;But I cannot make it work with other properties than anchorpoint. Maybe this is because of my misunderstanding of Speed VS Velocity and how it applies in the world of expression.
Could this expression be adapted to fit my needs, or should I go with the first one I was trying to adapt?
decay = 5;
freq = 3;
if (decay == 0) decay = 0.1;
if (freq == 0) freq = 0.1;
delay = freq/decay;
weight = 1/decay/10;
frameDur = thisComp.frameDuration;
function worldVelocity(TIME) {
worldVelocityX = (thisLayer.toWorld(thisLayer.anchorPoint,TIME)[0]-thisLayer.toWorld(thisLayer.anchorPoint,TIME-.01)[0])*100;
worldVelocityY = (thisLayer.toWorld(thisLayer.anchorPoint,TIME)[1]-thisLayer.toWorld(thisLayer.anchorPoint,TIME-.01)[1])*100;
return [worldVelocityX,worldVelocityY];
}
function worldSpeed(TIME) {
return length(worldVelocity(TIME));
}
timeStart = 0;
timeRestart = 0;
stop = false;
stopped = false;
for (i=timeToFrames(time);i>=0;i--) {
var t = framesToTime(i);
var tNext = t-frameDur;
if (worldSpeed(t) == 0 ) {
if (timeRestart == 0) timeRestart = t;
if (worldSpeed(tNext) !=0 ) {
timeStart = tNext;
break;
}
}
}
TIME = time-timeStart;
frameRestart = timeToFrames( time-timeRestart);
w = value
if ( frameRestart <= delay)
w = value - worldVelocity(time)*weight*(frameRestart/delay);
else
w = value - worldVelocity(time)*weight;
if (worldSpeed(time) == 0) {
spring = worldVelocity(timeStart) * ( .15/freq * Math.sin(freq * TIME * 2 * Math.PI) / Math.exp( TIME * decay ) );
w + spring;
}else{ w; } -
Remi Monedi
February 28, 2020 at 11:36 am in reply to: OVERSHOOT expression only based on Velocity – NOT keyframesTo calculate the velocity I found several methods, I tried them all and got to those conclusions :
The difference : property-property.valueAtTime(time-.01)
The velocityAtTime(), but I couldn’t get it to work with a property, maybe this is my mistake.
The .speed function, simple enough, I chose this one.Then I tried to tweak your overshoot expression Dan, this time, with a property of only 1 array, the Rotation of Null “A” (to make things easier).
Here is the expression of the Rotation of Null “A” :
linear(time,0,0.1,0,180);And the expression of the rotation of Nul “B” :
// —– REFERENCE PROPERTY —–
ref = thisComp.layer(“A”).transform.rotation;
refvelocity = ref.speed// —– OVERSHOOT —–
freq = 3;
decay = 5;t = time – inPoint;
dur = 0.1;
if (refvelocity != 0){
ref
}else{
amp = 180/dur;
w = freq*Math.PI*2;
ref + amp*(Math.sin((t-dur)*w)/Math.exp(decay*(t-dur))/w);
}It works but I have 2 problems to fully “automate” this expression, mainly because when it comes to time in expression, I’m very quickly lost :
1. the duration of the animation “dur” is a value, but it could be :
dur = Moment when “refvelocity” change its value back to 0 (end of a movement) – Moment when “refvelocity” change its value to something different than 0 (start of a movement)
2. the amplitude “amp” is a value too but it could be
amp = Value of “ref” when “refvelocity” change its value back to 0 – Value of “ref” when “refvelocity” change its value to something different than 0
Is it possible to get those informations?
If yes, which expression should I use, or how you should I write it? -
Remi Monedi
February 27, 2020 at 9:39 pm in reply to: OVERSHOOT expression only based on Velocity – NOT keyframesNothing in particular since I was thinking of the most versatile expression (the position of “A”could be set with expressions, another layer, keyframes). This is why I thought of its velocity as the main reference for its motion.
The expression you’re talking about Dan, it can’t watch for the velocity during the whole composition?
-
Remi Monedi
January 13, 2019 at 7:11 pm in reply to: Optimize Renser Speed by understanding comps, layers, expressions and effectsHi everyone, sorry for the late reply and Happy New Year!
Thank you Dave for your answer! Actually I should have added the mention PREVIEW SPEED with RENDER SPEED in this Thread title. This is why I was asking very specific questions. I want to find the best/fastest way to work, preview and render complex projects in AE.
To help me answer it, I finally decided to make some simple test in AE, here are my conclusions :1. BECAUSE even set to its “dead” value, an effect takes time to render,
(for instance a Displacement Map effect with Horizontal and Vertical Displacement value set at 0%)
> THE FASTEST WAY to “deactivate” an effect is to set the opacity of the ADJ layer to 0% (if it’s on an Adjustment layer)
> OR the other way is to set the effect opacity (in Compositing Option) to 0%2. 1 ADJ LAYER with a X EFFECTS is FASTER than X ADJ LAYERS with 1 EFFECT (each) which is also FASTER than X COMPS with 1 ADJ LAYER with 1 EFFECT.
3. Expressions are calculated each frame and makes preview/render slow
> Use keyframe if possible : Convert Expression to Keyframe
> Avoid Math function expression if possible
> Use a script
> Make expression more efficient (How ?)If there are simple tricks to make expression more efficient, I’m interested!
Have a great day
-
Remi Monedi
December 30, 2018 at 1:19 pm in reply to: New impossible question : Adjustment Layer continuously rasterized[Michael Müller] “I don’t quite understand why you pre composed the adjustment layers in the first place.”
Hi Michaël, there are 2 reasons why I didn’t do all that in 1 big Adjustment layer.
1. For practicality, I used around 20 different effects that interact with each other through expressions and controls so I’d rather have One layer with the controls (the precomp) and the controlled layers inside (it could be 1 adjustment layer or several, doesn’t matter). If not, I will have a big mess of settings. And people are afraid of complicated settings.
2. Because I have a few adjustment layers with their specific Blending Mode, and since the effects I used don’t have an in-built blending mode setting I need to use the blending mode of the layer itself. So several Layers :/ (Calculations and CC Composite didn’t help)