particle-based viscoelastic fluid simulation
marcus • April 11th, 2008
amazing video by a clever canadian who has coded up a fluid simulation using particles, similar to what i’m currently working on in p5 – only that his one seems to be working ;-)
amazing video by a clever canadian who has coded up a fluid simulation using particles, similar to what i’m currently working on in p5 – only that his one seems to be working ;-)
hell, yeah!
– while working on the liquids code i realized that i need LOTS more particles to generate the level of detail i found in the analog photographs i did before. so after a few days of reading hundreds of opengl tutorials, research papers, game developers articles and 20+ p5 tests i'm finally getting closer to writing a particle system that can simulate 65k - 262k particles in real-time at 60+ fps. on my laptop (!), not a specialized über-workstation – in case you wonder.
that's a drastic increase over my previous java based system that could realistically do about 2k particles (10k was pushing it - ran at about 14 fps).
ill post some details on the new system soon, when its ready ...
when i saw the fountain a while ago, i was stunned by the amazing liquid effects photography chris parks did for their surreal space backgrounds and since then wanted to get my head around the dynamics in these systems.
now having finished our patashnik piece (will be blogging about it soon) i had some time to get into that subject. but before going directly to the code i got hands on ... with ink, olive oil, washing detergent, soy sauce.
here's what i got out of it after playing with it for a few hours.
» "liquids" on flickr.
its definitively amazing for me because normally i'd spend three months writing code before seeing a single image thats close to one of these photos. not exactly what you'd call "agile" ...
however speaking about code =)
i currently see two strategies to simulate this "liquid effect" in code:
a) do all the calculations for the complete area/ volume of the liquid.
this is the traditional approach and has been implemented a number of times.
however since your calculation costs increase exponentially with increasing resolution, it is impossible to generate hd images/ animations in realtime using this method, which is what i'm aiming for.
(i wrote a GLSL GPU-feedback based implementation a while ago, which works fine, even at higher resolutions, but is difficult to combine with other physical forces/ particle effects)
b) another approach i'm currently pursuing is simulating the fluid with a very large particle system where each particle varies in size to cover the complete area, therefore i'm currently rewriting/ optimizing my particle system to use multiple worker threads and improved opengl performance tricks (display lists, point sprites etc). that way i can now simulate 40.000 particles at 125 fps on my macbook pro – in java!
lets see where this goes...
by the way; the very talented maxim zhestkov also makes use of liquid effects in his latest video installation – very nice!