# Something wrong with how i handle terrain generation

I’m working on a procedural terrain generator.
At it’s core, my script goes through each point in the height map and assigns it a 1 or a 0 (50/50 chance)
I then use this noise to generate an organic looking map, which based on the height, either does or doesn’t peek over a “water” plane.

my problem is this: depending on the general direction the “coasts” are running, the height either appears as “smooth” (using 45 degree angles) or “stepped” (only traveling at a series of 90 degree angles.)

The image I provide is after a few iterations of my function that makes it look more organic. this issue shows up entirely at the random noise part, so i’m just providing this image to make the problem more clear.

“coasts” with a positive slope act like 2

“coasts” with a negative slope behave like 1.

I want the “coasts” to behave like example 2.

Anyone have any idea why the terrain is behaving like this?

The following code is how i generate my noise.

``````    void GenerateNoise()
{
for (int x = 1; x < Dx - 1; x++) {
for (int y = 1; y < Dy - 1; y++)
{
//give each point a 0 or 1
map1[x, y] = Random.Range(0, 2);
}
}
}

void ConvertMap(){
//convert the int map in to a float map for heights
for (int x = 0; x < Dx; x++)
{
for (int y = 0; y < Dy; y++)
{
map3[x, y] = (float)map1[x, y] / 30.0f;
}
}
}

void PrintMap()
{
ConvertMap();
ground.terrainData.SetHeights(0, 0, map3);
}
``````

sorry If this is confusing, trying to explain it as clearly as I can.
Please let me know how I can clarify.
THANKS!

Well you do “hard edges” in your terrain so you actually see the individual “Quads”. Have a look at this figure:

``````P0 ----- P1
|      / |
|    /   |
|  /     |
|/       |
P2 ----- P3
``````

Imagine all points are “high” except one. If P2 or P1 are low your quad becomes a concave mesh. So there will be a notch along the diagonal. However if you lower only P0 or P3 you get a convex mesh where the diagonal between P1 and P2 “stays” top. So in this case you actually get one triangle that is flat and one that is slanted downwards. However in the first case both triangles would be slanted.

Is this actually a 3d game? If not using the terrain seems a bit overkill.