1

I am working on a infinite world generated with Perlin Noise, Java and LWJGL. But I am having a problem, it is kinda hard to explain, so I made a video: http://youtu.be/D_NUBJZ_5Kw Obviously the problem is the black spaces in between all the pieces of ground.

I already tried making all the values doubles instead of floats, but that didn't fix it.

Here is a piece of code I am using:

float height2, height = (float)getHeight(x, y);

height2 = (float) ((getHeight(x-1, y+1) + height) / 2);
vertexhelper.addVertexColorAndTexture(x, height2, y+1, r, g, b, a, 0f, 1f);

height2 = (float) ((getHeight(x+1, y+1) + height) / 2);
vertexhelper.addVertexColorAndTexture(x+1, height2, y+1, r, g, b, a, 1f, 1f);

height2 = (float) ((getHeight(x+1, y-1) + height) / 2);
vertexhelper.addVertexColorAndTexture(x+1, height2, y, r, g, b, a, 1f, 0f);

height2 = (float) ((getHeight(x-1, y-1) + height) / 2);
vertexhelper.addVertexColorAndTexture(x, height2, y, r, g, b, a, 0f, 0f);

I loop through this at the initialization of a chunk with x->16 and y->16. vertexhelper is a class I made that just puts everything in a array.

(I am using floats here, but that's after doing the maths, so that shouldn't be a problem)

genpfault
  • 51,148
  • 11
  • 85
  • 139
Sietse
  • 707
  • 4
  • 10

1 Answers1

1

I had to take 4 places on the heightmap in account instead of 2. So instead of

height2 = (float) ((getHeight(x-1, y-1) + height) / 2);

I had to use

height2 = (float) ((getHeight(x, y-1) + getHeight(x-1, y) + getHeight(x-1, y-1) + height) / 4);

That fixed it.

Sietse
  • 707
  • 4
  • 10