I have a mesh that was created in a 3D program which is the terrain the player will walk on. I want to allow the terrain to be deformable by the player, but for it to be smooth (not like Minecraft).

From what I have read from existing questions similar to mine, I need to use an algorithm such as Marching Cubes (which I don't understand yet). From what I understand, those types of algorithms are suited for procedural generation.

My question is; How do I convert my mesh into voxels so that I can use algorithms such as Marching cubes?

Is it simply a matter of cutting up my mesh in chunks?

If it helps, I will be using C# and Unity 3D.

  • \$\begingroup\$ It works the other way around. You have data which you manipulate, then create the mesh from it with e.g marching cubes. \$\endgroup\$
    – ElDuderino
    Commented May 12, 2017 at 1:29
  • \$\begingroup\$ @DMGregory Thanks. I've edited my question, I hope that is better. I don't fully understand all the terminology, and am completely new to this area. Even some direction to beginner resources (articles, books) would be great. I'm not good at math, so am not sure how far I can even go with what I want to accomplish. \$\endgroup\$ Commented May 12, 2017 at 10:35
  • \$\begingroup\$ We don't just link to outside resources here, so if you're looking for beginner tutorials this isn't the right place to search. Now that you've mentioned your mesh is a terrain: is it heightmap-based? If you don't need sharp overhangs, caves, or tunnels, and the player only raises and lowers the terrain (or mooshes it side to side a little), then this can be done in a much simpler way without voxelizing or rebuilding the mesh at runtime. Would that suit your needs, or do players need to be able to dig out deep tunnels and the like? \$\endgroup\$
    – DMGregory
    Commented May 12, 2017 at 12:34
  • \$\begingroup\$ Don't reinvent the wheel. Get this $49 asset to do it for you. \$\endgroup\$ Commented May 12, 2017 at 13:59
  • \$\begingroup\$ @DMGregory My mesh is just something I created in Blender, so it's not using a heightmap. Ideally I would like them to dig tunnels. \$\endgroup\$ Commented May 12, 2017 at 14:57

1 Answer 1


If you are interested in procedural terrain generation I suggest first this article.

Also I try to correct your thinking of this.

Most important, Voxels are what you are searching and which are the output of the map generator. A mesh though is describing the surface of an object which can be displayed by an engine.

Voxels in more detail are scalar values without an dimension which are used for being distributed equal over a dimension.

This means, they are simply values in a space describing whether a position in space is in an object or not in an object.

So what's all that about, why Voxels? The Voxels represent world data very well and can also be edited easily (they fit into human thinking). Also the result of surface extraction of Voxels is always predictable. Meshes are not suitable for changing the world, they aren't in am easy editable format and can be broken easily.

How is the workflow?

  1. You create data aka Voxels with the procedural map generator

  2. You need to extract the so called "isosurface" from the voxel data.

In short, you need to find a valid surface representation of your voxel data.

How to achieve this?

One algorithm would be Marching Cubes, however out there are even more algorithms and so far I know unity already has build in helpers for Voxel data.

The iso surface then is a mesh which can be displayed.

  • \$\begingroup\$ Thanks, but I don't actually want to create terrain from scratch using procedural generation. I want to use an existing mesh I created in Blender where I can let the player dig into the terrain. \$\endgroup\$ Commented May 12, 2017 at 15:01
  • 1
    \$\begingroup\$ I understand @JackPotatoeFan, this is more difficult and requires to know which format the terrain file has and how it's build. \$\endgroup\$ Commented May 12, 2017 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .