This was really satisfying to demo on the bus. I held my phone up as still as I could and when the bus lurched forward or made an abrupt stop the fluid responded accordingly. Something about it was just beautiful. Tech imitating nature. The illusion held pretty well too. Good job Google/Apple for making good sensor data and this algorithm uses it well. Great job!
Fantastic read! Not to diminish the original contribution here, but I got curious and started looking for similar projects on the native (in my case iOS / Metal) side that aren't part of the usual suspects like game engines.
The technique this is based on doesn't create those satisfying tension effects but is more similar to paint flowing on a surface of water, so from a tangibility perspective I'd still love to find something closer to this post's work that runs natively.
There are two difficulties you'd encounter adapting those techniques to this simulation:
1. The curved boundary is somewhat annoying to handle when your simulation is done using square grid cells.
2. Empty space introduces some really annoying boundary conditions. You'll notice that those two examples fill the entire region with fluid.
It's entirely doable, but the boundary conditions probably triple the implementation effort when compared to a square box entirely full of fluid. As a wise man once said, "90% of the work in fluid simulations is dealing with boundary conditions."
Super interesting article -- it broke down the steps of the simulation algorithm very clearly and the code samples supplemented the theoretical explanation well. I've been learning D3.js recently (working with force-directed graph simulations) and this reinforces a lot of the concepts I've encountered in learning graph simulations with D3.
The scroll response is backward, but otherwise very cool! When I scroll down, the ball goes up the screen, but the liquid goes up as well, whereas in real life it would be compressed towards the bottom of the ball.
Very nice demo but it seems that the gyroscope data from my phone is interpreted wrong. When I hold my phone with a left tilt the fluid flows to the right. Using iPhone XS with iOS 12.1.3
Thanks, I'll try that, I'm not really happy with the behaviour at the edges yet. In hindsight it proved to be one of the most difficult things of the whole simulation!
> wish I had this when I was learning molecular dynamics
Keep in mind, though, that the article only outlines a way to make fluid drops look realistic, and doesn't actually guarantee anything about whether the behavior is realistic.
Yes, the wall should probably exert a repelling force just like very close fluid particles do (except that the entire displacement is applied to the fluid particle, because the wall doesn't move).