Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inverted Smoothstep?

I am currently trying to simulate ballistics on an object, that is otherwise not affected by physics. To be precise, I have a rocket-like projectile, that is following an parabolic arc from origin to target with a Lerp. To make it more realistic, I want it not to move at constant speed, but to slow down towards the climax and speed up on its way back down.

I have used the Mathf.Smoothstep function to do the exact opposite of what i need on other objects, i.e. easing in and out of the motion.

So my question is: How do I get an inverted Smoothstep?

I found out that what i would need is actually the inverted formula to smoothstep [ x * x*(3 - 2*x) ], but being not exactly a math genius, I have no idea how to do that. All I got from online calculators was some pretty massive new function, which I'm afraid would not be very efficient.

So maybe there is a function that comes close to an inverted smoothstep, but isn't as complex to compute.

Any help on this would be much appreciated

Thanks in advance,

Tux

like image 531
Tuxedomask Avatar asked Sep 16 '25 02:09

Tuxedomask


1 Answers

Correct formula is available here: https://www.shadertoy.com/view/MsSBRh

Solution by Inigo Quilez and TinyTexel

Flt SmoothCubeInv(Flt y)
{
   if(y<=0)return 0;
   if(y>=1)return 1;
   return 0.5f-Sin(asinf(1-2*y)/3);
}
like image 120
Esenthel Avatar answered Sep 17 '25 18:09

Esenthel