Water Droplet through Metaballs

CMPS 161 - Winter 2002
Justin Onstine - wildone@cats.ucsc.edu

For my final project, I decided to create a realistic looking model of a droplet of water falling into a pool of water. Ideally the splash and the ripples would have been modeled as well. In order to model the droplet of water a technique called "Metaballs" or "Blobby Models" was used. Inverse raycasting would be used to model the reflections/diffractions of light as it passed through the liquid. Now let's get down to what I acutally finished.

Due to a computer malfunction halfway through this project (with no backups or previous versions) progress was slow. I was able to figure out and implement the idea of metaballs (which will be the focus of this writeup) and that's about it. For the life of me, I could not get texture mapping to function properly.

Metaballs

Metaballs is a process which uses a function to define a field strength eminating from a point (or set of points for multiple metaballs) and traveling throughout the 3D environment. A threshold value is then defined at which the edge of the ball is drawn. For my project, I used the following function:

1/(distance)^2

where distance = sqrt((x0 - x)^2 + (y0 - y)^2 + (z0 - z)^2). This draws a perfect sphere.

Next, the field must be rendered at the threshold value. This is accomplished through the Marching Cubes algorithm which we studied briefly in class. Basically, the 3D environment is split into a number of different cubes or voxels. The value of the field is calculated at each vertex of the current cube and if the threshold value is between two of the vertices then the edge intersection is noted. There are a total of 256 ways in which the cubes may be intersected and each way produces a unique set of triangles that are to be drawn. After every cube is marched through, the set of triangles created by the edge intersections creates the surface.

So at this point you're probably saying, "Yee-haw, we have a sphere that is created in O(n^3) time. What's the big deal?" A single metaball is not that exciting granted, but when several are created in the same space, things become a bit more interesting. When multiple metaballs are around, the field strength is combined at each point in the 3D environment. Thus, each metaball creates a contribution based on its distance from the point. With the combination of the contributions, the balls appear to connect to each other, much in the same way that water droplets do when they get close enough to each other (see snapshots). The shading is done using vertex normals and Jane Wilhelms' shading library (thanks!). The code for the Marching Cubes algorithm was borrowed and studied from Nikos Lalas (thanks!).


Click here to see a short video



Justin Thomas Onstine