# directx volume terrain

This topic is 957 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I want to make my terrain 3d- add underground caves, mining option etc.

How can I edit 2d grid? I tried with simple face moving but it doesnt expand grid of course.

I want to achive something like this

using the easiest way. Any tips?

##### Share on other sites

but I cant imagine how it exacly works :/

Any examples in directx?

Marching cube is this black cube on video, but what is isosurface?

Edited by widmowyfox

##### Share on other sites

Marching cube is this black cube on video, but what is isosurface?

An isosurface in this case is the boundary between the "inside" and the "outside" of the object -- it's the thing you're trying to compute so that you'll have your terrain :)

##### Share on other sites

ok now I am totally lost , thanks  :D

I want to lean on http://paulbourke.net/geometry/polygonise/

There's  isosurface (it's the thing you're trying to compute so that you'll have your terrain) so what is this box and how can i get position of vertices? Is it volume of terrain?

ohhh and one more: What is isolevel and how can I get it?

I need voxel grid for that, right?

Another example

Edited by widmowyfox

##### Share on other sites

but I cant imagine how it exacly works :/

Any examples in directx?

Marching cube is this black cube on video, but what is isosurface?

The black cube in the video is not "marching cube". That's just the guy's editing cursor, a visual marker to show the location he's looking at to edit.

Marching cube is an algorithm, or set of steps, that can convert a density field function to a mesh.

An isosurface can be described as the set of all points where the density function is equal to some value, this value being the "isolevel".

To start with, you need to understand that your volume terrain is going to basically be a mathematical function that for some input (x,y,z) will return a value, or density, at that location. This output value is typically a floating point value in the range of 0 to 1. So any given coordinate location within the bounds of your world or level will have a corresponding density value. The iso-level parameter determines where the boundary between "solid" and "open" lies. If you set iso-level to 0.5, then any (x,y,z) location whose density value is less than or equal to 0.5 is considered "solid", while everywhere else is considered open.

The tricky part in this type of thing is generating a mesh that follows the iso-surface of the density function at the threshold of iso-level. The Marching Cubes algorithm is one such technique. It operates by splitting the volume up into discrete cubical cells, and evaluating the density function at each corner of each cell. Cells where some of the points are "solid" and others are "open" are considered to be parts of the iso-surface, and the algorithm will generate a small bit of mesh geometry for this cell, representing a divide between the solid and open cells. Once all surface cells are evaluated, the resulting pieces of geometry are consolidated to form the surface mesh of the volume.

The term "marching cubes" comes from the mental metaphor of cubes "marching" across the surface of the volume, since an optimization in the algorithm includes starting at a known surface cell and recursing out to neighbors of that cell that are ALSO surface cells.

##### Share on other sites

>> Marching cube is an algorithm, or set of steps, [snip]

a most lucid explanation!

+1

i'd heard of it, but never looked it up. with just that short explanation you provided, i now understand what it does and how it works. a most clever algo.

##### Share on other sites

thanks, I understand now, one more question:

All of these is how to generate 3d grid base on volume-density data, but how can I edit this grid (videos). Is it editing base on isolevel changes?I already have grid base on height map and I only want to make it editable.

##### Share on other sites
If you store your terrain as a 3D grid of values, then you can edit the terrain by changing the value stored at a particular location. You can generate your mesh using marching cubes, using the 3D grid as the density function. Each cell of the 3D grid would be interpreted as a corner point for a set of cubes. Editing operations could be either binary (set a particular array location to either 1 or 0) or smooth (add or subtract a small increment). Smooth editing would result in smoother mesh generation.

As for isolevel, you just pretty much determine what you want that to be when you start. Set it at, say, 0.5 and then you don't usually change that again. That's simply the arbitrarily-chosen value of where you locate your iso surface.

##### Share on other sites

But this will require dynamic buffer and calculate all triangles every time even when i dont edit anything.

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633657
• Total Posts
3013198
×