3

I've been working on a 3D procedural world for a while now and am wanting to start adding cave systems.

I'm wanting to find a fairly simple method of creating 3D cave systems in a procedural manner. I'm currently generating my world using Perlin Noise, 2D for elevation/detail, 3D for carving out overhangs and smaller caves, but I'm getting stumped when it comes to long interconnecting caves.

I'm hoping to get something more like Minecraft's cave systems. They seem to be very very connected, branch off randomly in nearly any direction, and nearly any point in the cave would have a fairly circular look with a fairly equal radius throughout (not the best wording, but not quite sure how else to put it).

The biggest challenge for generating caves like I'm wanting is that I want to generate the world on the fly. The world is generated chunk by chunk currently, starting where the player is and it generates outwards from there. I would NOT want to generate any of the world and then dig the caves out using a wandering pattern, cellular automata, etc.

A good example:

enter image description here

tshepang
  • 12,111
  • 21
  • 91
  • 136
Mythics
  • 773
  • 1
  • 10
  • 19

1 Answers1

0

I'm going to make some considerable assumptions about your generation algorithm when generating your world.

You are creating a world similar to that of Minecraft. This means the world is made of blocks and the absence of those blocks is what makes up the "air" or the player space. So as you are making blocks in the world you want to not place block or conversely remove placed blocks where you wish there to be caves. OK?

How you generate the caves, which are essentially negative space, is really up to you. But in your question possibly lies your answer. Caves are "very very connected, branch off randomly in nearly any direction, and nearly any point in the cave would have a fairly circular look with a fairly equal radius throughout". All you then need is a generation algorithm that produces to that specification and either doesn't place blocks there or removes blocks already placed or in your own words "digs out".

As a side note it sounds a rather bad idea to have the generation algorithm generate from where the player is, but I suppose if it works.

ceorron
  • 1,230
  • 1
  • 17
  • 28
  • The result of my generation is indeed just air vs land (-1 to 1). I use Marching Cubes to smooth out the terrain. Yes, I am looking for an algorithm to create the negative space exactly as I described, but that's where I'm falling short. What algorithm would do such a thing? How exactly is generating from where the player is and moving outwards a bad thing? I wouldn't start with the chunk below them as they could be standing on dirt within their current chunk, resulting in the player shifting upwards vs 'falling'. – Mythics Aug 03 '12 at 21:16
  • I would try to think of the world as one thing (the thing that need generating to your specification, that specification may include caves that are separate but inform the world placement algorithm, a derivative of Perlin Noise by the sound of it, that of the presence of negative space).If your are creating a height map then it wont be possible to create convex things such as caves you will have to convert to some kind of mesh first. Think of the player as something different that can be placed in the world once it has been generated. Understand? – ceorron Aug 03 '12 at 21:40
  • If you iterate through every Y value per x/z, you can sample your noise one time for that whole column and set density values as you go. Then, offset those positive density values by your 3d noise to carve out your caves/overhangs/etc. This eliminates floating terrain. Either way, I know I can carve out caves using my method as I have done so, but getting them the way I want is escaping me, hence my being here. – Mythics Aug 04 '12 at 00:09