red hot lava!

Well it took long enough! I've been wanting to write a Lavalite screensaver for at least ten years, and I finally figured it out, thanks to more mining of Paul Bourke's fine pages. (Of course, it also helps that computers have gotten 30x faster in the intervening time.)

This is a combination of metaballs (alternative explanation here) and marching cubes. Basically, each bubble of lava is a few (4) overlapping spherical metaballs of various sizes that are following similar but slightly different steep, slow parabolic arcs from the bottom of the jar to the top and back. They are "30% fuzzy", so as they get near each other, they deform and combine. Then, for each frame, I generate a surface by running marching squares over it: basically, for each point in an NxNxN grid, you ask "is this point inside, or outside an object?" and from that, you can generate a lattice of triangles.

It's really slow. Just like real lavalites. Of course, if I wanted to do a proper simulation, I'd have it just sit there doing nothing for the first three hours after it started up. Somewhat surprisingly, the slow part is generating the scene, rather than rendering it: usually with 3D programs, it's the other way around.

Tags: , , ,
Current Music: Cabaret Voltaire - L21ST