MetaBalls

3D Metaballs


Realtime 3D Metaballs using C#, Feel free to attempt to write it in Javascript,

To see some webplayer samples go to []

To use the code, simply make an empty object, then attach a Mesh Filter and Renderer and the script, and bring the camera up close because it will be one unit in height,width, and depth. The code is commented and to modify the metaball movement just change Update and Start to modify the amount of blobs, their positions and intensities.

I'm happy that the Metaballs seemed to work well, although assigning a new mesh every frame began to consume memory at a quick pace and stopped doing so after about 500MB (noticeable in the first demos, I will post updated versions later). The current implementation reuses the mesh, but suffers from having a lot of empty triangles that (I think) are rotated and processed anyways when they aren't used by the marching cubes implementation. Is there any way to limit the amount of triangles that are processed in the triangle list, or to manually free the memory used by a previous mesh?

The code uses a Marching Cubes algorithm, and does a few things, such as trying to process only the cubes around the mesh surface, and processing the normals from the unitization of the addition of all the power derivatives of the blob. One way it could still be updated is trying to only process cubes where the mesh faces the viewer for opaque surfaces.

Hope you enjoy, I had fun writing it.