i try to simulate the corner-pin effect in ae, and i use the inverse bilinear method(https://iquilezles.org/articles/ibilinear/) to do this, but i found the strength direction is different from the same in ae.
// if edges are parallel, this is a linear equation
if( abs(k2)<0.001 )
{
res = vec2( (h.x*k1+f.x*k0)/(e.x*k1-g.x*k0), -k0/k1 );
}
// otherwise, it's a quadratic
else
{
float w = k1*k1 - 4.0*k0*k2;
if( w<0.0 ) return vec2(-1.0);
w = sqrt( w );
float ik2 = 0.5/k2;
float v = (-k1 - w)*ik2;
float u = (h.x - f.x*v)/(e.x + g.x*v);
if( u<0.0 || u>1.0 || v<0.0 || v>1.0 )
{
v = (-k1 + w)*ik2;
u = (h.x - f.x*v)/(e.x + g.x*v);
}
res = vec2( u, v );
}
return res;
}
the first one is mine, and the other one is result in ae enter image description here enter image description here
i want to get the same effect as that in ae, how to change the code or any other better ways to achieve that?