Greg Borenstein's NoMM Page

Bouncing Ball Assignment


Bouncing ball in GLSL from Greg Borenstein on Vimeo.

Since shaders are stateless, we can't use the same forces-based incremental simulation as in the other examples below. We need a function that returns the position of the bouncing ball merely as a function of time given a series of constants (starting height, rebound coefficient, initial velocity, etc.). The best account of that analysis I've found is here: The Mystery of the Bouncing Ball.

UPDATE (2/11/14): After more work on this, I figured out a shortcut. Even though I couldn't derrive an equation for all bounce times, I realized I could calculate the amount of time between each bounce as a series. Given the ball at the ground plane, it has an upward velocity at a given bounce which is its initial velocity multiplied by the rebound factor once for each bounce that has ocurred. Given this initial velocity and the effect of gravity since the time of the last bounce, we can calculate the timing of each bounce. By knowing the time elapsed we can figure out where we are in the bounce cycle by looping over a fininte number of bounces. Even though this doesn't give a full function for every bounce time, it works well enough to simulate the bounces over a given time period.

Note: based on the analysis linked above, it should also be possible to calculate the total amount of time after which the ball will come to a stop. With this in hand, we could figure out the number of bounce intervals we need to calculate.


This is in-progress. Does not fully implement the math linked above, simply a ball falling under gravity with an initial velocity.




Same animation logic as the Processing example below (without the squash), but animating a div. The text "ball" could be a NYTimes article and the animation would work the same way.



Incorporated a "squash" factor that both reduces upward bounce and alters the shape of the ball.