# Small question about procedural terrain generation

Am I getting it right, that when I’ll make a single mesh that represents terrain using unity’s built-in 2d perlinnoise function, then I’ll be able to somehow add caves using whatever (perlin worms for example)? Or do I need to find solution with 3d noise?

No.

Unity’s built in perlin noise function is 2 dimensional. And it can be used to produce a height map.
Caves are 3 dimensional. Meaning you’ll need to poke holes in the heightmapped terrain and stuck a cave inside… OR…

You’ll need to look for 3 dimensional version of perlin noise.

However, 3d perlin noise will not produce a terrain, but rather something similar to a cloud.

And to turn 3d perlin noise into a mesh you’d need marching cubes algorithm, voxelization or something similar.

1 Like

what I’m trying to do is make a voxel procedural world similar to Cube World or Minecraft. Most guides through the internet use Mathf.PerlinNoise so that’s why I ask.

Research to be continued.

Perlin noise ALONE will produce a smooth cloud-like structure. Like the one in the gif I uploaded. Even if it s a “cube world”.

To make minecraft terrain you’ll need multiple noise patterns, they’ll need to be altered, filtered, combined and so on. For example, you could make a base 2d pattern which will create a heightmap, then could combine it with 3d noise to make it uneven, then you could combine it with additional noise iteration to make caves.

For example, this is also perlin noise:

And this is what happens if I start combining multiple noise functions.

Not exactly a “cave”, but going in that direction.

Basically, regardless of what you do, landscape generation can be thought of as a function that for any given point in space returns density (and type of the matter there).
So, you start with a function that returns density based on a heightmap produced by a perlin noise. Then you combine it with a function that carves holes and cave systems. Then you blend them together in such way that areas close to surface do not turn into swiss cheese and only a few tunnels are produced near the surface, while a lot of them are created underground.

That’s the rough idea of it.

A small addition: Cube World is 2013 game that procedurally generates its world as Minecraft. I added this as it seems you don’t know about the game. However, overall I got your idea

I remember this thread having a lot of information about creating a minecraft-like world