# Algorithms for large scale deformable terrain with multiple heights, i.e. not heightmap based

Every search I do results in heightmap based terrain, where you can't have a tunnel, or cave, etc within the terrain.

What good algorithms are there to do this kind of deformable terrain?

I'm aware of voxel based terrains, however I would like to explore not necessarily aligned, mesh based ones.

• wave function collapse and it's multiple variations, else just make multiple seamless meshes and arrange them procedually then fuse them into one.
– Cei
Jul 18, 2023 at 21:39
• Can you describe what you mean by "arbitrarily aligned mesh based ones"? If you want tunnels, you'll need a mesh with arbitrary topology — so either tiles you assemble, or that you generate on the fly marching cubes / dual contouring style (which I guess could be argued to be small tiles with a post-process distortion). Jul 18, 2023 at 22:24
• @DMGregory Fixed it. I shouldn't have used "aligned" there. I meant to say not aligned really.
– gak
Jul 19, 2023 at 1:06
• Can you describe what you mean by "not aligned", then, to help us understand what needs to be different from the usual approaches sketched above? Jul 19, 2023 at 1:17
• @DMGregory I mean not necessarily aligned to a grid. Mesh vectors can be at arbitrary positions.
– gak
Jul 19, 2023 at 5:19

## 1 Answer

A height map defines a height for each point of your plane tessellation mesh grid. So it is defining an offset on the vertical axis. Or, if you will, vertex displacement on the vertical axis.

Using a height map the traditional way to get overhangs is to add meshes on top of the terrain.

As alternative, instead of defining just a displacement on the vertical axis, you could define displacement on all axis... That is, you could define a vector. It can still be a texture, except you use separate color channels for each axis.

That is, you would use vector field displacement maps. Yes, it is similar to vector displacement map in sculpting software, but I'm NOT asking to dynamically tesselate your mesh - to be fair, you could.

First of all, this means that you can use the map to move the points along the plane of the terrain. Which means you can move points away from areas that need less detail, and towards areas that need more detail.

And once you have additional points in the areas where you need them, you can lift them off the terrain and sculpt them to make overhangs.

However, what I said above is NOT enough for a tunnel or a cave system. The reason being that we are displacing the vertex, but the topology is the same. Thus, a hole through one side of the terrain to the other (such as a tunnel) is not possible.

For that, you could define holes in the terrain. That is, you use a mask to decide which vertex to discard (e.g. alpha scissors). And then stitch in the hole another mesh which might or might not have been created with the same tools.

And, of course, as you are already aware, you could instead work with voxels or implicit surfaces (and mesh them with marching cube or similar approaches).