Having The Hardest Time With Cave Noise

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