Producing a smooth mesh from density cloud and marching cubes

Posted by Wardy on Game Development See other posts from Game Development or by Wardy
Published on 2013-04-12T13:37:27Z Indexed on 2013/11/08 16:18 UTC
Read the original article Hit count: 364

Based on my results from this question I decided to build myself a 3D noise map containing float values in place of my existing boolean point values. The effect I'm trying to produce is something like this, rather than typical rolling hills; which should explain the "missing cubes" in the image below.

If I render my density map in normal "minecraft mode" (1 block per point in the density map) varying the size of the cube based on the value in my density map (floats in the range 0 to 1) I get something like this:

voxel point cloud data

I'm now happy that I can produce a density map for the marching cubes algorithm (which will need a little tweaking) but for some reason when I run it through my implementation it's not producing what I expect.

My problem is that I'm getting something like the first image in this answer to my previous question, when I want to achieve the effect in the second image.

Upon further investigation I can't see how marching cubes does the "move vertex along the edge" type logic (i.e. the difference between the two images on my previous link). I see that it does do some interpolation, but I'm not convinced I have the correct understanding of what I think it should do, because the code in question appears to give the same result regardless of whether I use boolean or float values.

I took the code from here which is a C# implementation of marching cubes, but instead of using the MarchingCubesPrimitive I modified it to accept an object of type IDrawable, containing lists for the various collections (vertices, normals, UVs, indices), the logic was otherwise untouched.

My understanding is that given a very low isovalue the accuracy level of the surface being rendered should increase, so in short "less 45 degree slows more rolling hills" type mesh output. However this isn't what I'm seeing.

Have I missed something or is the implementation flawed and need to be fixed?

EDIT:

A little more detail on what I am seeing when I "marching cube" the data.

enter image description here

Ok so firstly, ignore the fact that the meshes created by the chunks don't "connect" (i'll probably raise another question about this later).

Then look at the shaping of the island, it's too ... square, from the voxels rendered as boxes you get the impression there's a clean soft gradual hill and yet from the image there are sharp falling edges even in the most central areas where the gradient in the first image looks the most smooth.

The data is "regenerated" each time I run this so no 2 islands come out the same, and it's purely random so not based on noise, but still, how can it look so smooth in 1 image and so not smooth in the other?

© Game Development or respective owner

Related posts about c#

Related posts about unity