Hacker News new | ask | show | jobs
by ohadpr 2379 days ago
"Marching Cubes remains the most widely cited visualization algorithm ever".

It's an awesome algorithm that takes an isosurface (imagine a 3D map of weights) and generates a polygonal mesh. This algo was heavily used in the demoscene and often referred to as 'meta balls'.

Video of animated isosurface rendered with marching cubes: https://youtu.be/PbH1TlnDYvo

2 comments

> This algo was heavily used in the demoscene and often referred to as 'meta balls'.

No. It is used to implement 'meta balls' effect sometimes. But the two terms are not synonymous. From my experience it's more common to see meta balls implemented with raytracing or some screen-space techniques.

The guy wasn't wrong, "A is often referred to as B", doesn't contradict "B isn't synonymous with A"
“Gears are often referred to as ‘pocket watches’” is not a correct statement, even though gears are sometimes used in the implementation of pocket watches.

Cf. https://en.wikipedia.org/wiki/Metaballs

But they _are_ sometimes referred to as metaballs, _at the same time_ as being used to implement them.
I'll give a shot at explaining isosurfaces in a little more detail.

The prefix iso- means "the same." An isosurface is a surface for which some value is the same at every point. Marching Cubes is used for creating a polygon mesh of a 3D isosurface, but it's easier to understand by first imagining the 2D case.

In two dimensions, you don't really have isosurfaces. As you lack the third dimension, you have isolines. You're probably familiar with those already when viewing terrain maps. The contour lines on terrain maps are isolines. They are drawn for some chosen height value(s) and as you trace along a line, every point on that line has the same height value. You can generate those lines using "marching squares", a 2D version of marching cubes.

I'm not terribly familiar with the details of the marching cubes algorithm, because I took one look at the tables I'd need to transcribe and decided not to implement it myself, but basically you split the world into a big grid. You query the values at the grid cell corners, and based on which corners are above or below the isovalue, you know what edges the isosurface passes through.

There's a table of shapes to that correspond to a given combination of corners in or out. For edges that have an intersection point with the isosurface, you then estimate its position on the edge by interpolating the two corners and finding the where it equals the isovalue.

The results of most VFX fluid simulations today are particles, and the distance to the nearest particle creates a distance field defined through all space. If you pick some distance value, you can then polygonize the isosurface with marching cubes. You'll probably also need a bit of smoothing, since otherwise the isosurface will be bumpy.

I'm not sure if films like Moana [1] actually polygonized their fluid isosurface before rendering it or if they directly solved the equation for the implicit surface during ray tracing, but the fact that I can't tell should give you some indication of the potential quality of the result.

[1]: https://www.sidefx.com/community/walt-disney-animation-studi...

IIRC, marching cubes also has a patent on it so many applications generating meshes from isosurfaces use slight derivations of marching cubes that generally speaking, accomplish the same goal. I don't know if this is still true (patented part).

Edit: the patent has expired and is in the public domain. Alternatives were used for many years though.