Cartoony Liquid Simulator

The idea is simple:

  1. Do a physics simulation of balls in a container (JBox2D)
  2. Render the simulation onto a raster.
  3. Blur the image.
  4. Apply a threshold.

What you're left with is a cartoon-ish, chunky liquid. Use the controls to see the components of this process.

The most computationally intensive step is blurring the raster. Convolution is expensive, O(n^2), and it's being done by the CPU here, rather than the GPU. To run at full speed, you need a nice computer.

See the Git repository for full source code listing.

Original idea: How to simulate liquid