top | item 19034132

Simulating blobs of fluid

178 points| peeke | 7 years ago |peeke.nl | reply

25 comments

order
[+] jastanton|7 years ago|reply
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!
[+] robin_reala|7 years ago|reply
Aside, but as peeke’s here: your articles are great. Any chance you could add an RSS feed so I can follow easily?
[+] peeke|7 years ago|reply
I'll have a look over the weekend!
[+] peeke|7 years ago|reply
It should be up now
[+] gdubs|7 years ago|reply
Meta point but I really like the design, typography, and color of the whole post. Nice work!
[+] alexfringes|7 years ago|reply
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.

These two are kind of fun to play with: https://github.com/andreipitis/FluidDynamicsMetal https://github.com/hagmas/MobileFluidSimulation

Both based on this approach, detailed here by Nvidia: http://developer.download.nvidia.com/books/HTML/gpugems/gpug...

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.

[+] slavik81|7 years ago|reply
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."

[+] buildlove|7 years ago|reply
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.
[+] learnstats2|7 years ago|reply
Did I miss a demo? I would have got more from this explanation if it also showed what it was talking about.
[+] rhema|7 years ago|reply
Yep, you missed it. It's at the top of the page / header.
[+] Varcht|7 years ago|reply
I didn't miss it but I was skeptical at the performance, I thought to myself "be cool if mouse wheel scrolling agitated it, OMG it does!"

Nice work, am a big fan of fluid sims too. Who says the internet is not fun anymore?

[+] huebomont|7 years ago|reply
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.
[+] Marioheld|7 years ago|reply
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
[+] tastyfreeze|7 years ago|reply
I was pleasantly surprised that scrolling made the fluid react to the motion. Very nice work both in writing and demonstration.
[+] dekhn|7 years ago|reply
very clear read; wish I had this when I was learning molecular dynamics. However, I suggest using bouncing term on the walls rather than sticking.
[+] peeke|7 years ago|reply
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!
[+] amelius|7 years ago|reply
> 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.

[+] caf|7 years ago|reply
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).