54 comments

[ 2.8 ms ] story [ 118 ms ] thread
Feels so smooth on my iPhone. I’m aware these phones have pretty killer SOCs but I couldn’t have imagined running this on something that fits in my pocket 15 years ago.
To be fair, first gen iPad also had apps like this. Not 15 years but...
It had apps like this, but I don't think there was anything as complex.
Would be interested in painting with this. Too much fun.
Doesn't show anything in Firefox Developer Edition? (Works fine in Chrome/Brave).
Works fine for me. I'm on 79.0
Me too, on Nightly/Android.

Tiny bit choppier than Chrome but fully working.

Beautiful! Would be awesome to have as a desktop background.
Screen on fire! Had a good fun
I understand why real 3D fluid sim is much harder to do at reasonable speeds than 2D but I wonder if there's a pseudo-3D version that would look good (I'm especially thinking of VR here)

A few transparent layers to add depth? Or something akin to parallax occlusion mapping?

EDIT - this Shadertoy is remarkably awesome despite only running on a 128x128x128 grid: https://www.shadertoy.com/view/wlG3RW

There's this paper which describes a simplified fluid dynamics appropriate for games: Real-Time Fluid Dynamics for Games by Jos Stam. You can find the paper and implementations by searching. It's based around numerical stability and speed, rather than accuracy. I think it would be interesting to put this into a simcity-like game to get good air pollution maps.

I'm not sure if this WebGL page is based around this algorithm.

What does that have to do with 3D versus 2D?
3D is hard to do in real time as you have many more grid points. The method I linked to is much faster than properly solving the fluid equations, so is suitable for a 3D interactive simulation.
The GitHub WebGL page is based on a GPU Gems article, which was based on Stable Fluids.

The ShaderToy 128³ cube appears to be quite different. I don't entirely follow what it's doing, but the pressure solve seems to be heavily simplified.

I recently came across EmberGen which seems to offer real-time volumetric fluid simulation [1] and I wonder what's driving it and whether it's down to the hardware, algorithm or something else?

1. https://youtu.be/iDqWLwYhd9Y

Parallax occlusion mapping is quite heavy itself, though. Transparent layers stacked on top of each other are also quite expensive due to overdraw.

Probably the cheapest way to add a little bit of 3D-ness would be to write the fluid sim to a texture, use it as a height map, and sample the texture a second time while offsetting the uvs slightly based on height map and camera position. Still not a great solution, and would probably only work if it was a wall of fluid in front of you.

Would love to see this as an audio visualizer.
On my iPhone 6S, I turned the quality up to high and played with the simulation for around five minutes. It kept working smoothly, but holy crap, I'm not sure if my phone has ever been this hot!

Great work though, it's gorgeous!

If anyone is interested, I made an implementation of this (based on the GPU Gems article) in Lua using the LÖVE framework that adds a bunch of effects like reflections, normal mapping and more.

https://sixtyfour.itch.io/fluid

I am interested. Thank you very much. Out of curiosity, why LÖVE? For thr added features?
I'm just a big fan of Lua for its simplicity and power, especially LuaJIT. LÖVE makes excellent use of it.
macOS?
macOS is a PITA, maybe with MetalVK or ANGLE there could be less pain; but OpenGL is in a sad state on macOS ever since they started becoming territorial about GPU APIs.
(comment deleted)
The app is well worth downloading, and given how much time I've wasted just futzing around in it, I was more than happy to pay a few bucks to unlock the additional features. Really superb.
Has anyone tried making any games or interactive music videos with this?
This is IMO a more relevant question than it seems. You'd think so, but it's absurdly rare to see real-world uses of demo techniques like this (not only talking about fluid-sims, here). I long wondered why this is (easy answer: because it's hard).

These things are often designed to run very efficiently and getting maximum effect out of limited hardware and memory. It's perfect for, say, a small indie game looking for a cool background effect or something. I'm sure there's examples, but I couldn't even come up with one.

The game PixelJunk Shooter [1] is a game that that takes advantage of fluid dynamics. They use a technique called "Smoothed particle hydrodynamics". Particle based techniques might be better suited for real time fluid dynamics.

[1] https://en.wikipedia.org/wiki/PixelJunk_Shooter

(comment deleted)
Great multi-touch demo.

Be sure to turn up the quality and res.

Could this be modified to make a lava lamp simulator?
Made me smile. The colors are great! :)
I opened this website expecting very little, as I know Apple has refused to deploy WebGL 2 (Apple is essentially always the stubborn bottleneck) and particularly as I am still running iOS 12.

It was glorious. It was smooth and responsive and maybe-weirdly fun to play with given how simple of a toy this little demo of a website itself represents. I had this momentary feeing of joy.

And then it popped up a dialog asking me to install an app. I think I want to go cry now about how fucked up the world is and how it is no longer possible to have good things on the web :(.

The controller in the upper right hand does not support higher resolutions directly, but you can edit higher resolutions into the select box and it'll absolutely accept them. I was able to push it up to 2048 no problem, though it is more interesting at 512 and 1024.
(comment deleted)