# Having The Hardest Time With Cave Noise

@nevir, @Squidgy, @lucadeltodecso, someone with some experience using 3D noise maps to create an interconnected cave system!

I realize it has a lot to do with experimentation and chaining 3D noise with Distortion, Lerp Interpolation and Remaps, etc. But if anyone has a good starting recipe, that’d be greatly appreciated. I’ve been messing around for hours with how to do this to create believable and accessible (!) caves with no real success. The problem with most of my attempts is that the 3D noise ends up “orphaning” a lot of cave areas with no connection to the caves that are accessible from the surface. Most of my cave network is useless (unless you know they’re there and can dig to get to them yourself).

Yeah, there’s a lot of different ways of creating caves; lots of experimentation necessary! Lemme walk through some of the foundational combinations of noise that you can build upon.

Something to keep in mind with caves: the cave function is applied as a mask over your terrain. I.e. a -1 indicates a cave, while 1 is a terrain block.

Perlin Caves

Probably the most basic; pipe perlin noise through an absolute noise function, and voilà:

These caves work pretty well, but they tend to degenerate into a bunch of small spherical-ish blobs towards the thinner ends of a cave. (See the smoothing strategy below)

Simplex Caves

Simplex caves tend to require a fair bit of smoothing. They tend to generate a mix of worm style caves (similar to perlin), as well as large cave “slabs” (see the large blue cave area in the front/center of this image).

I’m less of a fan of this style - far more difficult to manage.

Worley Caves

Worley noise is a bunch of combined spherical cells. Great for making small spherical rooms:

Try playing with the cell count, and cell size.

General Strategy

There are some common trends for most/all cave noise functions that you should consider:

Lower vertical frequency: I highly recommend scaling your noise so that `frequency.xy` is lower than `frequency.z`. This causes a more gradual vertical gradient in your caves:

A ratio of 1:2 seems to work pretty well in most cases.

Smoothing

The interpolated noise function does a decent job of combating caves that degenerate into a series of barely disconnected blobs:

Dealing With Biomes

It is generally best to specify your cave function globally (e.g. on the world node). Don’t forget that you can set the cave threshold on a per-biome basis. If you want some biomes to have larger caves, just crank that up!

By using the same cave function across all biomes, you can ensure that caves are seamless between biome transitions.

Surface Shrink

Surface shrink effects the cave threshold for caves near to the surface. Lower values cause caves near the surface to be smaller than normal (and higher causes caves near the surface to be larger than normal):

Note: This appears to be applied as a gradient over the entire height of caves. A value of `0.0` will completely remove your caves. You always want a value of `0.01` or greater.

This is very useful for reducing the chance of caves breaking through to the surface (especially in combination with `dropMaxDepth`).

For example, I managed to hollow out the mountains on Kovah, without breaking the surface, by having a low (but > `0.0`) surface shrink, combined with a high `caveThresholdBias`.

4 Likes

This is awesome information @nevir, thanks so much for putting this together! I will hit the WB tomorrrrow and try these suggestions out.

1 Like

Excellent post. @nevir you could teach our team a few things about the WB!

4 Likes

Okay, awake now. Thanks again @nevir, very helpful information.

I’ve been experimenting with all the different 3D noise maps piped through a ton of filters, etc. to try and come up with a map that looks like real caves. I think my problem is twofold: (1) a matter of perceived scale and (2) using the wrong visualization in the tool. I have been relying on the visualization of the resulting noise directly to determine whether it is appropriate for caves. However, as can be seen below, that’s not always an accurate way to do that. The image on the left is the result of the noise and the one on the right is the same noise hooked up to the “Caves” node at the world level and visualized using the world’s “Caves” visualization.

Not exactly an accurate picture of what’s going on in the visualization on the left.

The problem of perceived scale (what works in-world and what doesn’t) will be solved when I can actually play test my worlds.

Thanks again.

1 Like