Sign in to follow this  
widmowyfox

directx volume terrain

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 https://www.youtube.com/watch?v=-CPpcF4ycPU using the easiest way. Any tips?

Share this post


Link to post
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 https://www.youtube.com/watch?v=xfG-J-6eqqU

Edited by widmowyfox

Share this post


Link to post
Share on other sites

Yes and I read http://paulbourke.net/geometry/polygonise/
 
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
You will need to recalculate triangles only when a value is changed. You can also reduce the amount of recalculation that is performed by splitting your volume up into 'chunks', where each chunk is some arbitrary dimension of cells, and running marching cubes on a per-chunk basis. Then you only need to regenerate the chunks that are actually affected by the edit, rather than the entire landscape mesh.

Share this post


Link to post
Share on other sites

Wow, nice idea.  Maybe i dont have to recalculate all triangles but I still have to create dynamic buffer for each chunk :/

 

And I need to store a lot of volume data. What is the best way to increse speed? Binary files?

Share this post


Link to post
Share on other sites

Wow, nice idea.  Maybe i dont have to recalculate all triangles but I still have to create dynamic buffer for each chunk :/


Probably, yes.
 

And I need to store a lot of volume data. What is the best way to increse speed? Binary files?


Well, binary files are usually more quickly loaded than text files, yes. Other than that, you'll need to profile to find where your bottlenecks are, and try to apply optimizations as needed. Edited by JTippetts

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this