in development

we don’t need no interpolation

Polygonizing a scalar field takes time. The marching cubes algorithm is O(N³), so every unit of radius you want to polygonize increases the processing time by a factor of eight geometrically. The code that implements the scalar field runs within its inner loop. You’ll want this to be as fast as possible.

The set of functions (a) defined for all R³, (b) sufficiently interesting, and (c) fast isn’t a big club. We can create interesting surfaces by interpolating across noise sources (or pseduo-noise sources—see a few posts down), but a 3D interpolation is “fast” only in the sense of running in constant time.

Here’s a pleasant little alternative that I’ve been playing with.

var source = function(x, y, z) {

	var ix = Math.floor(x);
	var iy = Math.floor(y);
	var iz = Math.floor(z);

	return  Math.cos(ix * Math.cos(iy * Math.cos(iz)));
};

The marching cubes algorithm calls this function directly. There is no interpolation step, which cuts total runtime by an order of magnitude. Visually, it’s rough, but a start.

func

There are wide-open spaces and confined areas, plus that all-important sense of structure, making it something more than interpolated noise.

func2

It’s blocky, sure, but there are ways to modulate the field to round the surfaces. I’ll see what else I can come up with in future posts.