Simulating blobs of fluid
The passes consist of the following steps: Apply forces to the particles and advance their position based on their velocity Store the particles’ position in a spatial hash map for a fast lookup in later steps Calculate pressure and near-pressure for the particles’ location Contain the particles within a boundary Before we dive in, a performance consideration: since we’ll be looping over ~1000–2000 particles, it’s absolutely necessary that we use Typed Arrays. The first step in our algorithm is to update the particle velocities ( and ), based on the forces acting on the particles and advance their positions based on their new velocity. If a neighbour has the exact same position as our particle , the gradient value equals (very close).
Source: peeke.nl