Hacker News new | past | comments | ask | show | jobs | submit login
Simulating blobs of fluid (peeke.nl)
178 points by peeke on Jan 31, 2019 | hide | past | favorite | 25 comments



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!


Aside, but as peeke’s here: your articles are great. Any chance you could add an RSS feed so I can follow easily?


I'll have a look over the weekend!


It should be up now


Meta point but I really like the design, typography, and color of the whole post. Nice work!


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.


You might find this post by Jamie Wong interesting: http://jamie-wong.com/2016/08/05/webgl-fluid-simulation/

Doesn't seem to work on mobile though


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."


https://github.com/mmaldacker/Vortex2D

It should work on macOS/iOS via MoltenVK, but I haven't tested it extensively.

It's a hybrid simulation with particles for the advection and a grid to ensure incompressibility.


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.


Did I miss a demo? I would have got more from this explanation if it also showed what it was talking about.


Yep, you missed it. It's at the top of the page / header.


Ah, thank you. It doesn't display in my browser.


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?


On mobile it’s also responding to the accelerometer data. At least on my iPhone X. Very cool demo.


accelerometer also works on chrome on ubuntu on my laptop (which also has an accelerometer) win!


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


I was pleasantly surprised that scrolling made the fluid react to the motion. Very nice work both in writing and demonstration.


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.


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.


Jep, lot of shortcuts to make it run at 60 fps. It's most likely not very scientifically accurate.


the same thing could be said about molecular dynamics.


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).




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: