2D Metaballs

Filed under: Game Maker


The challange was to draw a 2d fluid. The solution was very interesting. Because actually solving marching cubes or similar was too slow in Game Maker, I designed an ‘analog’ approach. This works on a surface. First we draw whatever the fluid ‘world’ may be - that is, what the fluid area will actually show. Like a liquidy red version of the screen for blood, or a gradienty blue version for water, etc. Then we do a bit of magic and overwrite the alpha of that surface with the alpha of particles representing the fluid area. Last but not least, we achieve thresholding without alpha testing which is unsvailable in game maker by multiplying the alpha values by themselves several times much like the contrast ramp phase of a bloom filter.

The technique of overwriting a surface’s alpha chanel alone is useful in many other applications, but I’ll let you think about that.
Oh yeah one more thing. The demo itself looks different from both these screenshots. And probably less pretty. Fiddle with it yourself to achieve the style you want. You’ll be wanting to play with the step script, which is sufficiently commented to navigate.

Metaballs!

Related posts

Tags: , ,

Digg Sphinn del.icio.us Facebook Mixx Google

Permalink Comments (1) GearGOD Oct 2, 2007

One Response to “2D Metaballs”

  1. Miffyman Says:

    Very good, this fluid animation has potential! nice work!


Leave a Reply