noiseprocedural-generationperlin-noise

How does Minecraft generate thin 'Noodle caves'?


In this video Henrik Kniberg (a Minecraft dev) showed the method to generate thin "noodle" caves in 2D, which is treating the gray area on a perlin noise map as caves. That creates thin, curvy caves. As one of the comments rightly pointed out, "In 2D, it makes sense. But in 3D, it would cause floating blobs of stone to generate." And so he replied with the following:

For spaghetti & noodle caves we take two ridged 3d noises and intersect them. I visually think of it like this: imagine two hollow oranges with a thick peel. The two oranges slightly overlap in 3d space. Keep only the part where the two peels overlap. That gives you a thick ring. Make the ring hollow, and apply some randomness to it. Result: long squiggly tunnels. Was a bit tricky to explain in the video without making it too long, so I simplified it by just showing the 2d equivalent.

I don't quite get what he meant. I know that "ridged 3d noise" is a different kind of noise. But what part of the noise (black part, gray part or white part) is he treating as the "peel" in the orange analogy?

I also don't quite know what 3D ridged noise looks like. I think I should try and display what it looks like using the marching cubes algorithm, but I do not know how to implement ridged noise. Is there some noise library (for C#) that can do that? Or better, is there already a noise visualizer that supports ridged noise?

Any explanation would be appreciated.


Solution

  • Ridging is basically @Cadeyrn says: to take the absolute value of noise so that the range goes from [-1, 1] to [0, 1], and the behavior around zero forms a sort of V shape. I'll extend this here with more clarifying information.

    Think of the ridging as highlighting the parts of the noise where its value is near zero. Doing this in 2D creates 1D paths, but in 3D it yields 2D surfaces that wind throughout the space -- like a crumpled up piece of paper that goes on forever. You need to get back to 1D paths, but stay in 3D instead of 2D. A way you can do that is to overlay two noise instances with different seeds on top of each other, keeping only the 1D paths that come from the intersections between the 2D sheets.

    My own world gen creations typically see noiseA² + noiseB² used for this purpose, but Minecraft's |noiseA| + |noiseB| also works, giving the noodle caves their characteristic wall creases.

    If you picture a 2D slice moving up and down in your world, you shouldn't always see connected paths. If you did, it would imply that a player can always see a path forward without changing altitude. Rather, such a slice should reveal self-contained horizontal cross-sections as it cuts through caves that may not be oriented horizontally. Quick 2D visualization: https://www.shadertoy.com/view/stccDB

    It also can't go without my mention a caveat that this video goes best with: while it's illuminating on the specifics of Minecraft's generation, it's also regressive in that it furthers an unmitigated-Perlin-first mindset for noise. Perlin noise, out of the box, is smooth and random, but creates strong square directional bias that runs against a goal of natural pattern replication. Perlin was the first algorithm out of a now-broader general set of Gradient/Coherent noise, which includes the newer Simplex noise. The actual Perlin algorithm isn't necessarily the best choice nowadays, without explicit mechanisms in place to address its artifacts. Watch the video, absorb its teachings, but take its Perlin-framed language with a grain of salt. I went into more detail on this issue in my article here.