martinm07 / particle-fluids

Implementing "Position Based Fluids" by M. Macklin et al. using Three.js for GPGPU.
MIT License
0 stars 0 forks source link

Particles pushed on top of each other at moving boundaries #4

Open martinm07 opened 7 months ago

martinm07 commented 7 months ago

In the current setup with two walls and a floor, at both corners when the walls move towards one another, particles that used to inhabit that space are naturally pushed with them. However, this may happen to land them directly on top of another particle. The two will now stay glued together for the rest of time, acting as particularly dense, with other particles staying far away and being violently repelled otherwise. To address this, we just need to make the particles strongly repel each other at these close distances. One potential thing we can do is add a near-pressure term (as described in this paper). Which may also help other aspects of the simulation. Another thing we might have to do is notice that this stacking is only happening because the particles are stuck on the plane of the floor, without any conception of the y-axis. If so, we might want to artificially introduce a bit of random movement, that's visually imperceptable but introduces some numeric instability to bump things back into the y-axis.

martinm07 commented 6 months ago

1.6.0 Addresses this somewhat by adding a small random change to W in GPUC3 if the distance between two particles is sufficiently small, which should give them different updates and seperate them. This does partly work, however particles can still remain stacked for periods of time before actually seperating.