Readit News logoReadit News
EsportToys commented on Physically Based Rendering in Filament   google.github.io/filament... · Posted by u/indigo945
petermcneeley · 4 days ago
I use the page to test scrolling.
EsportToys · 4 days ago
Nice, it's also a great test for my https://github.com/EsportToys/LibreScroll
EsportToys commented on I'm Unsatisfied with Easing Functions   davepagurek.com/blog/easi... · Posted by u/ndyg
pahgawk · a month ago
true! I suppose you'd risk getting some oscillations in the anticipation depending on the scale of the force, but that could be desirable, or might not happen if the scale is small enough, and certainly makes the math a little easier
EsportToys · a month ago
You can trivially calculate the time-to-peak overshoot using the closed form equation. It’s the first (0-indexed) zero of the velocity response, i.e. happens at t = (pi / scale)

And obviously it would only apply for the underdamped case.

EsportToys commented on I'm Unsatisfied with Easing Functions   davepagurek.com/blog/easi... · Posted by u/ndyg
MITSardine · a month ago
I don't imagine stepping through the ODE with finite differences at the same time step as drawing should be very expensive, essentially it's a handful of sums and products. In fact, using a closed form solution with an exponential is probably more expensive.
EsportToys · a month ago
A middleground is to use fixed timesteps with the closed form solution. Then the integration factors can be statically precomputed as constants, and every frame becomes just a 2x2 matrix multiplication.

And even if you are to calculate the integration factors based on dynamic frame rates, they only need to be computed just once per frame for all objects that share the same damping configuration.

Deleted Comment

EsportToys commented on I'm Unsatisfied with Easing Functions   davepagurek.com/blog/easi... · Posted by u/ndyg
joenot443 · a month ago
Wow, this is excellent!

Is there a name for this kind of motion? I'd love to use it sometime.

EsportToys · a month ago
It’s the general solution to a damped harmonic oscillator/mass-spring-damper system:

    m * x’’ + c * x’ + k * x = f(t)
See https://web.archive.org/web/20230604215211/https://esporttoy...

Deleted Comment

EsportToys commented on I'm Unsatisfied with Easing Functions   davepagurek.com/blog/easi... · Posted by u/ndyg
EsportToys · a month ago
Closed-form (non-iterative) PID solution:

https://www.desmos.com/calculator/mu80ttc9aa

   function sprung_response(t,pos,vel,k,c,m)
      local decay = c/2/m
      local omega = math.sqrt(k/m)
      local resid = decay*decay-omega*omega
      local scale = math.sqrt(math.abs(resid))
      local T1,T0 = t , 1
      if resid<0 then
         T1,T0 = math.sin( scale*t)/scale , math.cos( scale*t)
      elseif resid>0 then
         T1,T0 = math.sinh(scale*t)/scale , math.cosh(scale*t)
      end
      local dissipation = math.exp(-decay*t)
      local evolved_pos = dissipation*( pos*(T0+T1*decay) + vel*(   T1      ) )
      local evolved_vel = dissipation*( pos*(-T1*omega^2) + vel*(T0-T1*decay) )
     return evolved_pos , evolved_vel
   end
For anticipation, just add an extra initial velocity in the opposite direction and let the closed-form solution handle the time evolution. The main trick here is to keep both position and velocity as state. There is no need to “step through the simulation”.

u/EsportToys

KarmaCake day175July 23, 2022View Original