I think I’ve come up with an elegant solution on how to generate voxel caves that is worth sharing with the world. It allows procedurally generating voxel caves without any context/iterative approach, using just 3D Periln noise.

The end result can look something like this:

What you see are basically intersections of two 3D Perlin noise isosurfaces. What is an isosurface? Isosurface is “a surface that represents points with a constant value within a volume of space”. In human language, we use areas where the 3D Perlin noise has a certain value, for example when it’s 0 +- 0.1. This is how things would look like with just a single isosurface:

And here is the code for that (the ~number denotes noise octave size in blocks*16, # is just a random seed):

`Bool isCave = abs(perlin3D(~2, #3543)) < 0.1;`

Here is the exact same formula, except inverted:

Okay, now we take two different Perlin noises and do an intersection:

`Bool isCave = abs(perlin3D(~2, #3543)) < 0.05 && abs(perlin3D(~2, #43264)) < 0.05;`

And, in inverted version, we get this:

We get a complex cave system that is all interconnected. We can further play with the idea with using multiple noise octaves, varying thresholds, etc., but I’ll leave that to you 🙂