GPU Metaballs
Posted: December 20th, 2008 | 5 Comments »I've been meaning to implement this idea for ages, it's a GPU implementation of 2D metaballs. It's very simple, very fast and doesn't even require hardware shader support. Seems like the kind of effect that could be useful in some little game..

It's quite fun to play with (use left drag to rotate the emitter), so I might try and fancy it up with some better graphics and collision.
The demo is below, I'll probably release source at some stage but at the moment it's all tied up in my dev framework which needs to be cleaned up (the exe is also larger than it should be as I have all sorts of crap linked in).
The simulation is just done using my simple particle system but it would be fun to implement smoothed particle hydrodynamics..
{ 5 Comments » }
indeed i would fancy looking at the code to understand how it's done
cool demo
cheers
I would also be interested in seeing the code or at least some explanation about the process used in this demo.
Thanks.
OK the technique is really really simple. Here are the basic steps:
1. Set up a particle texture like the one in the demo, so that it's alpha channel represents density falling off from the center (any shape will do, experiment with different falloffs)
2. Render a whole lot of these to a render target with additive blending, this create's a 'density texture'.
3. Enable alpha-testing, and blit the density texture to the back buffer. The alpha threshold will affect the 'viscosity' of the fluid.
Hope that helps
Miles
Hi,
Thanks for the demo and the explanation. Do you think your approach can work on OpenGL ES 1.1 devices such as the iPhone or an Android device?
thanks!
That looks great and very fast. Any chance to get a look at the code?
Good job!