Techniques for creating underground caverns and tunnels

Started by
12 comments, last by KdotJPG 9 years, 6 months ago

I have been thinking about creating an experimental game that is set primarily in underground caverns, tunnels, and so forth. I've experimented a lot with games containing terrains and skies and so forth, but haven't done anything involving underground situations. I've seen games with underground locations that consist of square or round tunnels and so forth but I'd like to create something more natural, like caves that have formed naturally or been dug into the rock in such a way that it's natural looking.

My first thought is to model it using a 3d modelling package like Blender to create a mesh of the caverns.

I don't know if this is a suitable way of doing it, for performance reasons, not to mention memory usage and rendering, etc. I thought I'd ask for advice on the forums here and hopefully someone can provide links or suggestions on this topic that I can investigate and learn. I'd like to know what options are viable so I can research and learn and make the best choice for my project.

Further details if it helps. I'm currently using Unity3d but I've got some experience with a number of other engines as well as creating my own projects using c++.

Advertisement

I am not an expert, but a few points:

  • Yes, you could model the whole thing in Blender.
  • Depending upon the size of the caverns, modelling it all as one piece could be bad memory-wise and performance-wise.
  • Some approaches re-use cavern/tunnel/stalactite segments.
  • Like many modelling issues, judicious use of reusable and one-off assets can work well.

I have never worked on something like that, but if you want it procedural, 3D perlin noise comes to mind.

-* So many things to do, so little time to spend. *-

One simple option is to overlay 2 heighmaps, one becomes the ceiling the other the floor. All kinds of tunnel-forms that you can't easily create with just 2 heightmaps though - but clever use of heightmaps in other ways might still be an option.

Tiling together segments of tunnel is probably one of the best used techniques. You could even procedurally generate segments if you didn't want to model them in Blender or whatever.

There's also Voxel Terrain. This can be particularly suited if you need to dynamically dig through your terrain to create tunnels/caverns/etc. If you render the voxels as boxes you get a Minecraft-looking world. If you render the voxels using a clever isosurface algorithm (e.g.Marching-Cubes), you get a smoother more natural looking terrain.

I've gotten good results with using 2 layers of ridged Perlin noise:

4Ye0CRE.png

I described the technique here and again, later, in Game Developer Magazine. The post is lengthy, scroll down to Caves and Tunnels. It regards Minecraft-style block worlds, but as dmatter indicated you can use the same exact technique with a different surface generator (marching cubes, marching tetrahedra, dual contouring, etc...) to get smooth rather than blocky areas.

Essentially, a single octave of ridged Perlin noise in 3 dimensions, scaled and clamped to output either 0 or 1, looks like this:

cave_ridged.jpg

If you take two of them with different seeds and multiply them together, you get:

cave_base.jpg

If you want them a little more rough-looking, apply some turbulence using additional Perlin noise layers to perturb the input XYZ coordinate:

cave_turb.jpg

Inverting the cave structure and integrating it with a volumetric terrain:

ground_final.jpg

For other techniques, I dipped into my stuff all the way back to 2004 and found an old tutorial I once wrote for creating 2D cave systems by aggregating random circles together. (It's an old site I no longer maintain, filled with dead links and old info.) I began with a seed circle and iterated, generating additional circles and appending them onto the ever-growing structure at random locations.

afractal1.png

This technique, combined again with isosurface generation, could be extended to 3D using spheres. For additional visual interest, I would probably apply some noise perturbation as before.

caverns are typically done as a single level (skyrim), or as a level made up of seamless chunks that are tiled together to make a level (oblivion).

the levels / chunks can be created in a modeler (such as blender), a custom level editor (such as doom's, etc), or procedurally (as described above).

visible surface determination algo's such as b-trees and quad subdivide are commonly used for such scenes, especially when the poly count for a level is high, compared to the available processing power. someone doing indoor shooters can tell you more about that than i can.

to generate caverns for caveman, i simply start with a solid level map (all walls) and carve out spaces and halls. combine that with height mapped floors and ceilings and you get a decent effect with low effort and low overhead.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

I do like noise-based caves a lot, but I judged it as a level of complexity higher than the OP was aiming for.

Having said that, if we are talking about noise-based caves, traditionally you end up with some sort of density function. If you're cool with some parts being pre-generated rather than everything on-the-fly, I like the idea of making some caves look mined/explored by eroding the less dense rocks in a purposeful way, e.g. to get to particular deposits or to join caves together. You could pick targets and use a form of A* to do the mining. You could even do cave-ins based on tunnels and rock strength to add flavour.

Thanks for all the replies. For further clarification. Initially at least the underground area I want to begin with is something I want to have as a small settlement within a large cave. So, the look I want to achieve is something of a natural cave that has sections which have been "mined" or carved into stairs or rooms, etc. Parts of the cave will be modified and have a more structured look in around the natural cave.

All the info on the Perlin noise and voxel terrains is great, thanks. I will do a lot more research into those techniques which may prove quite useful, especially as I expand beyond this initial location.

I'm not sure if using a noise method like that will allow me to add features to the cave itself (such as stairs or rooms cut into the stone), which brings me back to thinking about the modelling of the initial cave environment and then looking at using the noise techniques to exapand the caves out into tunnels and adjoining caves as required.

Rather than model the entire thing in Blender perhaps it's possible to use a Perlin noise technique such as described by JTippetts to generate an initial cave structure. Combining that with a Marching-Cubes or similar technique to generate a natural looking cave structure. Then convert that to a mesh and make the modifications. However I suspect that this would result in a rather complex mesh and I'd be better off creating a less detailed mesh and using bump mapping to add surface details afterwards?

Rather than model the entire thing in Blender perhaps it's possible to use a Perlin noise technique such as described by JTippetts to generate an initial cave structure. Combining that with a Marching-Cubes or similar technique to generate a natural looking cave structure. Then convert that to a mesh and make the modifications. However I suspect that this would result in a rather complex mesh and I'd be better off creating a less detailed mesh and using bump mapping to add surface details afterwards?


This is the technique I would use, personally. It's much easier to generate the noise-based initial structure and perform custom modifications on that, than it is to build the man-made stuff first and try to fill in natural details later. You don't really have a whole lot of control over exact tunnel placement with noise.

If you use single-octave ridged functions, the result is like the third picture I posted. If you use an isosurface instead of block surface generator, the result is very smooth. I roughen the caves up using additional noise, but if the additional mesh complexity is not desired then it can be skipped and surface texture applied using bump/normal mapping instead.

Rather than model the entire thing in Blender perhaps it's possible to use a Perlin noise technique such as described by JTippetts to generate an initial cave structure. Combining that with a Marching-Cubes or similar technique to generate a natural looking cave structure. Then convert that to a mesh and make the modifications. However I suspect that this would result in a rather complex mesh and I'd be better off creating a less detailed mesh and using bump mapping to add surface details afterwards?


This is the technique I would use, personally. It's much easier to generate the noise-based initial structure and perform custom modifications on that, than it is to build the man-made stuff first and try to fill in natural details later. You don't really have a whole lot of control over exact tunnel placement with noise.

If you use single-octave ridged functions, the result is like the third picture I posted. If you use an isosurface instead of block surface generator, the result is very smooth. I roughen the caves up using additional noise, but if the additional mesh complexity is not desired then it can be skipped and surface texture applied using bump/normal mapping instead.

Thanks. I will read your article and do more research into this method.

This topic is closed to new replies.

Advertisement