[HN Gopher] Show HN: A simple 2D fluid and gravity simulation wi...
       ___________________________________________________________________
        
       Show HN: A simple 2D fluid and gravity simulation with WASM and
       WebGL
        
       The little particles will gravitate to your cursor (or touch
       location), and can even enter stable orbits if the conditions are
       right!  Mainly an excuse for me to experiment with wasm and WebGL,
       but it makes for a surprisingly good fidget toy.
        
       Author : aestuans
       Score  : 86 points
       Date   : 2024-05-08 05:30 UTC (2 days ago)
        
 (HTM) web link (aestuans.github.io)
 (TXT) w3m dump (aestuans.github.io)
        
       | gorjusborg wrote:
       | https://github.com/aestuans/blob
        
       | nand-less wrote:
       | This is really neat. I bet if you made the blobs follow a target
       | point that moved around randomly it could make a good screensaver
       | animation.
        
       | airstrike wrote:
       | This is great! If you're looking for ideas on how to extend it,
       | I'd love to be able to play with some of the parameters, or have
       | presets to pick from. At some point I tried spinning it like a
       | pizza dough but obviously these are way too liquid for that
        
       | rigid wrote:
       | mobile users should tap the canvas for the particles to move.
        
         | mentos wrote:
         | or shake the phone
         | 
         | Is the accelerometer data available?
        
           | rigid wrote:
           | yep. android 13
        
       | bun_terminator wrote:
       | aww why does it not follow my finger as it does my cursor? this
       | would be so fun!
        
         | aestuans wrote:
         | Good point, added touch support :)
        
       | fidotron wrote:
       | How did you decide to divide the work between the wasm and webgl?
        
       | rcarmo wrote:
       | This has great potential as a cat toy (provided you get a tough
       | touchscreen)
        
       | tetris11 wrote:
       | super slow on Firefox, naturally
        
         | seanisom wrote:
         | Working fine for me on Firefox - their WebGL support tends to
         | be good enough, although there are plenty of other resource
         | issues.
        
         | mft_ wrote:
         | 60 fps for me in Firefox, with the processor <1% while running.
         | 3060Ti was working, but not hard.
        
         | taberiand wrote:
         | Works without issue on my phone, Android Firefox
        
       | vrtnis wrote:
       | very cool! if you're exploring wasm for graphics, take a look at
       | Wander- lets you create and execute "renderlets" -- portable
       | modules containing graphics data and code compiled to wasm
       | https://github.com/renderlet/wander
        
         | CSMastermind wrote:
         | This is probably a dumb question but I assume anything
         | leveraging WASM can only run on the CPU?
        
       | justin_kempton wrote:
       | Beautiful!
        
       | seanisom wrote:
       | This is pretty cool - great to see what a small codebase can do
       | with raw WebGL. Have you looked at WebGPU at all?
        
         | aestuans wrote:
         | I wanted something that can run everywhere and WebGPU support
         | is still behind some flags in Firefox and Safari I think, but
         | I'm pretty excited about trying that as well.
        
       | Its_Padar wrote:
       | Very nice! Took me a while to realise it has mouse based gravity
       | but very good! (I clicked directly on the link on a mobile device
       | without checking here)
        
         | aestuans wrote:
         | Thank you. Yeah mobile support was an oversight from me, I
         | added touch support now.
        
       | jzting wrote:
       | Nice use of smooth union SDFs :)
       | 
       | I did a similar thing in 3D here:
       | https://generator.artblocks.io/62000470
        
       ___________________________________________________________________
       (page generated 2024-05-10 23:00 UTC)