# Marching cubes leaving holes in the mesh

Hi I'm trying to reproduce GPU Gems 3 chapter 1 (Generating Complex Procedural Terrains Using the GPU) and so far I managed the basics... Now I'm betting some strange output.

I started with the suggested -ws.y to generate a plane. Then when I moved to the noise I noticed some holes in the mesh. But unlike this previous question.

The noise mesh: So I decided to try something more simple, 3 tubes: x^2+y^2-2 x^2+z^2-2 y^2+z^2-2 I would assume there is some problem with the z axis. But I can seem to figure out what. My function to get the triangles vertex positions also seems ok...

Vector3 vertexAlongEdge(int edge, Voxel v){
Vector3 result=new Vector3(0,0,0);

Vector3 p1=v.vertexes[edges [edge, 0]];
Vector3 p2=v.vertexes[edges [edge, 1]];
float v1 = density (p1);
float v2 = density (p2);
if (Mathf.Abs (isoLevel - v1) < 0.00001)
return p1;
if (Mathf.Abs (isoLevel - v2) < 0.00001)
return p2;
if (Mathf.Abs (v1 - v2) < 0.00001)
return p1;

float m = Mathf.Abs((isoLevel - v1) / (v1 - v2));
result.x = p1.x + m * (p2.x - p1.x);
result.y = p1.y + m * (p2.y - p1.y);
result.z = p1.z + m * (p2.z - p1.z);

return result;
}


The only thing I can think of right now is an error in my table with the edges for each case. Please help.

• Any chance back-face culling is the issue? Unity expects front-facing tris to have their points in clockwise order. Nov 16 '14 at 23:16
• if that was the case they would be visible from the outside I suppose. But they are not. Nov 16 '14 at 23:29