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..

metaballs

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).

Demo

The simulation is just done using my simple particle system but it would be fun to implement smoothed particle hydrodynamics..

3 Comments

  1. indeed i would fancy looking at the code to understand how it’s done

    cool demo
    cheers

  2. I would also be interested in seeing the code or at least some explanation about the process used in this demo.

    Thanks.

  3. 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


Post a Comment

*
*