title: Using noise to generate marching cube terrain?
body: <p>I've succesfully made a marching cubes class in C# XNA and am using Lib noise to generate 3d perlin noise, but when I tried to generate terrain using the values of the perlin noise as the densities for my marching cubes it generates a large chunk of marching cubes with seemingly random triangles inside of them.  I separated the marching cube and gave it arbitrary 3d arrays of densities to run through so I could make sure everything was working and it looked fine, and I had the terrain generation code generate normal cubes and I got a normal looking terrain, but the problem is the corners of each cube gets values from the noise are always switching from negative to positive so fast that the marching cubes just look like a jumbled mess.</p>
  
  <p>This is the code I'm using to generate the terrain: </p>
  
  <pre><code> public MarchingCube[, ,] getTerrainChunk(int size, int stepsize)
      {
          MarchingCube[, ,] temp = new MarchingCube[size / stepsize, size / stepsize, size / stepsize];
          for (int x = 0; x &lt; size; x += stepsize)
          {
              for (int y = 0; y &lt;size; y += stepsize)
              {
                  for (int z = 0; z &lt; size; z += stepsize)
                  {
                      Vector3[] corners = { new Vector3(x,y,z), new Vector3(x,y+stepsize,z),new Vector3(x+stepsize,y+stepsize,z),new Vector3(x+stepsize,y,z), new Vector3(x,y,z+stepsize), new Vector3(x,y+stepsize,z+stepsize),
                         new Vector3(x+stepsize,y+stepsize,z+stepsize), new Vector3(x+stepsize,y,z+stepsize)};
                      float[] densities = { GetDensity(corners[0]),GetDensity(corners[1]),GetDensity(corners[2]),GetDensity(corners[3]),GetDensity(corners[4]),
                                              GetDensity(corners[5]),GetDensity(corners[6]),GetDensity(corners[7])};
                      if (x == 0 &amp;&amp; y == 0 &amp;&amp; z == 0)
                      {
                          temp[x / stepsize, y / stepsize, z / stepsize] = new MarchingCube(densities, corners, device);
                      }
                      else
                          temp[x / stepsize, y / stepsize, z / stepsize] = new MarchingCube(densities, corners);
                  }
              }
          }
      return temp;
   }
  </code></pre>
  
  <p>and the GetDensity method is as follows:</p>
  
  <pre><code>private float GetDensity(Vector3 point) 
  {
    return (float)terrain.GetValue(point));
  }
  </code></pre>
  
  <p>I think the problem is that I'm not using the noise correctly to get the densities of the marching cubes corners, but so far my google search results haven't been much help at all. So does anyone know how to use the noise properly to generate smooth looking terrain? Or what else may be causing this problem? </p>
  
  <p>I posted screen shots at <a href="http://imgur.com/a/D1uMC" rel="nofollow">http://imgur.com/a/D1uMC</a>   , the first two are shown using marching cubes and the last one is normal cubes. </p>
  
  <p>Edit:
  So from the pictures I figured out that the marching cubes are actually working how they are supposed to with the values they are being given, the problem is defiantly with my noise and how I"m using it. Does anyone know any good resources for 3d terrain generation based on noise? </p>