7 ms·
Liquid Layers
For more context, background see author's posts here: https://twitter.com/kotsoft https://twitter.com/kotsoft
- deleted 2y ago[deleted]
- Nzen 2y agotl;dr this is a liquid simulation toy. This starts with four colors of different densities (so they self-organize into layers). Clicking allows scooping up a ball of the liquid. I consider this pretty to watch, like a laval lamp that I can also throw globs of.
- TeMPOraL 2y agoYou also have a settings UI, where you can change (among many other things) what clicking does. I find it most interesting to switch to "repel" - the repulsion forcefield turns to be an universal tool for mixing and separating the different liquids, depending on how fast and precisely you operate it. Fascinating.
- kotsoft 2y agoWith keyboard there are also the shortcuts: 1-4 to emit the different materials a/r to attract repel from mouse x/c to rotate a bit
- yayitswei 2y agoSuper fun to resize the window and watch the liquid slosh into the new space.
- ssl-3 2y agoSuper fun on mobile to dig into the settings and turn on the accelerometer and gyro, and give the phone a twist and a shake.
- hopfog 2y agoThe author is also working on a really impressive voxel physics engine: https://youtu.be/3259aycYcek https://youtu.be/3259aycYcek
- pornel 2y agoI'm surprised the simulation is run on the CPU! This problem has solutions that fit the GPU well, even for grid<>particle conversions.
- deleted 2y ago[deleted]
- troglobite 2y agothis kind of sims are better suited for CPU ;-), gpu are good to work on meshes, not really on pure particles. At GPU are super good for grid based hydro.
- lukan 2y ago"gpu are good to work on meshes, not really on pure particles" Why? Having thousands of particles, all in need of doing the same operations on them in parallel screams GPU to me. It is just way harder to program a GPU, vs a CPU.
- thegeomaster 2y agoCollision detection is usually a tree search, and this is a very branching workload. Meaning that by the time you reach the lowest nodes of the tree, your lanes will have diverged significantly and your parallelism will be reduced quite a bit. It would still be faster than CPU, but not enough to justify the added complexity. And the fact remains that you usually want the GPU free for your nice graphics. This is why in most AAA games, physics is CPU-only.
- kotsoft 2y ago
- deleted 2y ago[deleted]
- BugsJustFindMe 2y agoAre there compressible liquids? I'm seeing the whole thing bounce like the layers are compressing.
- pornel 2y agoThis is a common and difficult problem when simulating fluids using particles. It's possible to simulate using a grid instead, and that computes pressure very precisely, but it has a downside of adding inaccurate viscosity. And there are tricks that combine both approaches to balance out the errors.
- kotsoft 2y agoYeah agree. The objective was more to make a physics toy that would run on single core on a phone than something for actual scientific or industrial use. I could add additional iterations or do pressure projection but then there would be complaints about it being slow & choppy. There are also some large density ratios between the materials which further increased the difficulty, and would also increase the number of pressure projection iterations on a grid. I tried to simulate buoyancy without cheating (e.g. giving different materials different acceleration to gravity)
- whisk 2y agoSuper fun!
- amelius 2y agoWas hoping for accurate simulation of laminar flow.
- sBqQu3U0wH 2y agoCool, the performance is significantly better than the previous time. Or is it a different kind of simulation?
- kotsoft 2y agoThis is still the same kind of simulation, based on the Particle-based Viscoelastic Fluid Simulation paper. I updated it to use Wasm SIMD more fully with the help of Clang Vector Extensions, Compiler Explorer and Wasm Analyzer. Compiler explorer to play around with patterns and Wasm Analyzer to double check the final compilation.
- eigenvalue 2y agoReally awesome work. The WASM lets you show this off to a massively larger audience than a regular binary. I'd encourage you to make your Voxel project also using WASM, then you can easily turn it into a mobile/tablet game.
- kotsoft 2y agoThanks! I am definitely working on bringing more to the WASM world. I'd begun experimenting with 3D and multithreading and then last week decided to circle back to the 2d demo and polish it up a bit more.
- imzadi 2y agoThis is interesting. I wish the other interactions were as dramatic as the drag one. You have to really crank up the brush size to see anything interesting.
- troglobite 2y agoAwesome!
- hermitcrab 2y agoThis is really impressive. Especially the performance in a browser.
- sphars 2y agoFYI, in the Interaction settings you can enable accelerometer and use gyro. Lots of fun on mobile devices! Works well for me on Android/Firefox
- shinze 2y agoImpressive
- d--b 2y agoI really wish these were 3D simulations. The 2D ones are always a bit off to me...
- CaptainOfCoit 2y ago"3D Liquid WIP Preview" https://kotsoft.github.io/pvfs3d/ https://kotsoft.github.io/pvfs3d/ From the description of "WebAssembly Liquid Simulator" https://www.youtube.com/watch?v=phXwC6HxWEQ https://www.youtube.com/watch?v=phXwC6HxWEQ Incredible stuff.
- kotsoft 2y agoThanks! With 3D the main challenge might be visualizing the layers separately. Ideally each of the phases would have some kind of metaball effect and also be transparent and even refract. Will be pretty tough to do and will have to fight with uncanny valley effect. Sometimes for sandbox I feel like 2D can be more fun because people can target particles they interact with better. Maybe WebXR will be good for the 3D version.
- Voltage 2y agohttps://david.li/fluid/ https://david.li/fluid/
- owork138 2y ago[dead]
- miohtama 2y agoiPad accelerometer is 90 degrees off
- vanderZwan 2y agoWasn't this shared a week/few weeks ago? Not that I mind it being posted again, just that if it was already posted it might be worth linking the old thread, in case there was some interesting discussion there.
- kotsoft 2y agoYes, the previous one is: https://news.ycombinator.com/item?id=40429878 https://news.ycombinator.com/item?id=40429878 There are some new features since then and some major speed improvements from using SIMD. I do still see complaints about the compressibility so I still need to work on some improvements for that. (dev)
- vanderZwan 2y agoThank you for digging up the link! And the bonus "release notes" ;)
- owork138 2y ago[dead]
- ta435747 2y agoThat link just goes to the libgenis home page (although cool site! will have a look around). All I could find from the OP so far is: https://www.reddit.com/r/VoxelGameDev/comments/ecxiyw/voxels_w_material_point_method_physics/ https://www.reddit.com/r/VoxelGameDev/comments/ecxiyw/voxels... that has a few links to a YT demo and some papers referenced.
- kotsoft 2y agoHi, I've updated the home page on my site (https://grantkot.com https://grantkot.com) with links to my other socials, like the YouTube and itchio pages. Twitter for more casual frequent updates, and YouTube for longer summary updates. The itchio demos need to be optimized for a wider variety of machines.
- fx18011 2y agohttps://sandspiel.club https://sandspiel.club is also interesting
- dctaflin 2y agoIt also takes into account surface tension. Bubbles of denser/lighter materials cling to the interfaces, rather than sinking or rising.
- Anotheroneagain 2y agoWhen you set all materials to the same density, you get a cold surface, with hot matter below it.
- anotheryou 2y agoWould be fun to add an emulsifier :) (particles that bond with 2 colors)
- wiz21c 2y agolet's do a mayonnaise!!!
- kotsoft 2y agoYou actually can adjust the settings for this. In settings>simulation, instead of sameRestDensity being 8 make it 0 and make it higher for diffRestDensity. I recommend doing it with low gravity as well (you can get zero g by clicking enable accelerometer on computers without accel)
- butterNaN 2y agoI know this is asking a lot from what is already a bundle of fun, but I wish it also made noises, in fact my brain is already simulating some It's like a visual stim toy
- kotsoft 2y agoHere's a video of the spatial sounds system from my 3D sims: https://www.youtube.com/watch?v=0HJ5lMpWTXQ https://www.youtube.com/watch?v=0HJ5lMpWTXQ I will see if I can bring it to WebAudio.
- kotsoft 2y agoUPDATE: I've added a "hacker mode" for you all! You can now specify a userUpdate function and it will run it each frame. See my twitter post for a demo of it. https://x.com/kotsoft/status/1806362956294189299 https://x.com/kotsoft/status/1806362956294189299
- tomcam 2y agoDelightful. Runs like a bat out of hell on my older iPad mini 5th gen.