Hey so, I've been reading everything I can find on how to use the 3d perlin noise to generate overhangs and ridges but I seem to be not on the right track?This is what I got using this method:
Add two perlin octaves together. If they are under 0 I turn them into blocks. If they are over 0 I continue and move on to the next one.
Once the sum is under 0, I add the amplitude to them and then proceed. If they are under the water level I draw a lake/ocean over that certain level.. But
It seems I'm missing something, there are lots of random blocks everywhere and only some attached ridges.
It used to look like this with my old method:
What could I doing wrong? Here's my code for creating cubes:
for (byte chunkX = 0; chunkX < xyChunks; chunkX++)
{
for (byte chunkY = 0; chunkY < xyChunks; chunkY++)
{
biomeType = r.Next(0, 5);
for (int xAxis = 0 + (16 * (int)chunkX); xAxis < chunkWidth + (16 * (int)chunkX); xAxis++)
{
for (int yAxis = 0 + (16 * (int)chunkY); yAxis < chunkLength + (16 * (int)chunkY); yAxis++)
{
for (int zAxis = 0; zAxis < 5; zAxis++)
{
//15,10 | 30, 8 | 20, 5 <----- Octave 4/5 combos that are good so far
//float octave1 = PerlinSimplexNoise.noise((xAxis + worldSeed), (yAxis + worldSeed), 1, 0.0001f);
//float octave2 = PerlinSimplexNoise.noise((xAxis + worldSeed), (yAxis + worldSeed), 1, 0.0005f);
//float octave3 = PerlinSimplexNoise.noise((xAxis + worldSeed), (yAxis + worldSeed), 1, 0.005f);
float octave4 = PerlinSimplexNoise.noise((xAxis + worldSeed), (yAxis + worldSeed), zAxis, 0.009f);
float octave5 = PerlinSimplexNoise.noise((xAxis + worldSeed), (yAxis + worldSeed), zAxis, 0.03f);
//float cubeGroundBase = octave1 + octave2 + octave3 + octave4 + octave5;
float cubeGroundBase = octave4 + octave5;
if (cubeGroundBase > 0)
continue;
octave4 *= 20f;
octave5 *= 5f;
cubeGroundBase = octave4 + octave5;
if (67 + cubeGroundBase < 59)
cubeGroundBase = -8;
if ((67 + (int)cubeGroundBase) <= 64) //Check if water
{
int sandLevel = (waterLevel + 3) + (int)cubeGroundBase; //update sand level from base
Sand[chunkX, chunkY].Add(new Vector3(xAxis, sandLevel, yAxis)); //Add to water list
cubeCollision[chunkX, chunkY][xAxis, yAxis].Add(new BoundingBox(new Vector3(xAxis - .5f, sandLevel - .5f, yAxis - .5f)
, new Vector3(xAxis + .5f, sandLevel + .5f, yAxis + .5f))); //add bounding box to list
Water[chunkX, chunkY].Add(new Vector3(xAxis, waterLevel, yAxis)); //Also add to list
}
else //it's grass or dirt
{
int groundLevel = groundBase + (int)cubeGroundBase; //update ground level with base
Grass[chunkX, chunkY].Add(new Vector3(xAxis, groundLevel, yAxis)); //Add grass to list
cubeCollision[chunkX, chunkY][xAxis, yAxis].Add(new BoundingBox(new Vector3(xAxis - .5f, groundLevel - .5f, yAxis - .5f)
, new Vector3(xAxis + .5f, groundLevel + .5f, yAxis + .5f))); //add cubeboundingbox to list
Dirt[chunkX, chunkY].Add(new Vector3(xAxis, groundLevel - 1, yAxis)); //Add grass to list
}
}
}
}
}
}
I'm only doing 5 for the height? I'm not sure if that's even how you would go about doing this?