Jump to content

  • Log In with Google      Sign In   
  • Create Account


ReqPro

Member Since 24 Aug 2012
Offline Last Active Aug 29 2012 01:49 PM

Topics I've Started

Perlin Noise seamless chunks problem

24 August 2012 - 08:05 PM

Hey everyone!

First of all, hope this is in the right place Posted Image

I've been fighting with this for a long time now, and I think I've come to the point where I've stared myself blind on the problem.
Here's hoping one of you can help me Posted Image

Here's the thing; I've made a minecraft-type world, divided into chunks of each 32x32x128 blocks. I've got a perlin noise generator creating the heightmaps so that they'd (hopefully) be seamless.
I've come close, but there are some minor issues I just can't iron out.

As a picture says a thousand words, I'll attach a screenshot where I've highlighted the seams with a red line to highlight my problem.

Posted Image

Now as you can see in the image above, there are some quite steep (and not very seamless) seams...
I'm completely at a loss as to how I'm going to remedy this.

Any pointers?

Thanks in advance,
Req

Edit:
Whoops, might be an idea if I included the code Posted Image

Function call to generate and store noise:
[source lang="csharp"] private void AddPerlinNoise(float f, float o) { for (int i = 0; i < Width; ++i) { for (int j = 0; j < Height; ++j) { Heights[i, j] += o + PerlinNoiseGenerator.Noise(f * (i + Index.X * Width) / (float)Width, f * (j + Index.Z * Height) / (float)Height, 0); } } }[/source]
PerlinNoise class functions:
[source lang="csharp"] public static float Noise(float x, float y, float z) { int ix = (int)Math.Floor(x); float fx0 = x - ix; float fx1 = fx0 - 1; float wx = Smooth(fx0); int iy = (int)Math.Floor(y); float fy0 = y - iy; float fy1 = fy0 - 1; float wy = Smooth(fy0); int iz = (int)Math.Floor(z); float fz0 = z - iz; float fz1 = fz0 - 1; float wz = Smooth(fz0); float vx0 = Lattice(ix, iy, iz, fx0, fy0, fz0); float vx1 = Lattice(ix + 1, iy, iz, fx1, fy0, fz0); float vy0 = Lerp(wx, vx0, vx1); vx0 = Lattice(ix, iy + 1, iz, fx0, fy1, fz0); vx1 = Lattice(ix + 1, iy + 1, iz, fx1, fy1, fz0); float vy1 = Lerp(wx, vx0, vx1); float vz0 = Lerp(wy, vy0, vy1); vx0 = Lattice(ix, iy, iz + 1, fx0, fy0, fz1); vx1 = Lattice(ix + 1, iy, iz + 1, fx1, fy0, fz1); vy0 = Lerp(wx, vx0, vx1); vx0 = Lattice(ix, iy + 1, iz + 1, fx0, fy1, fz1); vx1 = Lattice(ix + 1, iy + 1, iz + 1, fx1, fy1, fz1); vy1 = Lerp(wx, vx0, vx1); float vz1 = Lerp(wy, vy0, vy1); return Lerp(wz, vz0, vz1); } private static float Lattice(int ix, int iy, int iz, float fx, float fy, float fz) { int index = Index(ix, iy, iz); int g = index * 3; return Gradients[g] * fx + Gradients[g + 1] * fy + Gradients[g + 2] * fz; } private static float Lerp(float t, float value0, float value1) { return value0 + t * (value1 - value0); } private static float Smooth(float x) { return x * x * (3 - 2 * x); }[/source]

PARTNERS