I am trying to implement a biomes system into a procedural terrain generation system. I made it so that the height multiplier of each terrain chunk changes based on which biome it is, but that results in the player being able to go under the map where two biomes meet. I am trying to make the edges of each chunk have a height of 0, so that they will connect properly. The issue is, the for loops don't seem to be starting at 0. I used to have the if statement that contains x <= 8 to be x == 0, but then nothing with the mesh would change.
for (int y = 0; y < borderedSize; y += meshSimplificationIncrement) {
for (int x = 0; x < borderedSize; x += meshSimplificationIncrement) {
float height;
if (x <= 8 || x >= 233) {
height = 5.0f;
//Debug.Log(height);
//Debug.Log("x" + x);
} else if (y <= 8 || y >= 233) {
height = 5.0f;
//Debug.Log(height);
//Debug.Log("y" + y);
} else if (y <= 32 || y >= 225) {
height = heightCurve.Evaluate(heightMap[x, y]) * heightMultiplier;
height = height / 1.5f;
} else if (x <= 32 || x >= 225) {
height = heightCurve.Evaluate(heightMap[x, y]) * heightMultiplier;
height = height / 1.5f;
} else {
height = heightCurve.Evaluate(heightMap[x, y]) * heightMultiplier;
}
int vertexIndex = vertexIndicesMap[x, y];
Vector2 percent = new Vector2((x - meshSimplificationIncrement) / (float)meshSize, (y - meshSimplificationIncrement) / (float)meshSize);
Vector3 vertexPosition = new Vector3(topLeftX + percent.x * meshSizeUnsimplified, height, topLeftZ - percent.y * meshSizeUnsimplified);
meshData.AddVertex(vertexPosition, percent, vertexIndex);
if (x < borderedSize - 1 && y < borderedSize - 1) {
int a = vertexIndicesMap[x, y];
int b = vertexIndicesMap[x + meshSimplificationIncrement, y];
int c = vertexIndicesMap[x, y + meshSimplificationIncrement];
int d = vertexIndicesMap[x + meshSimplificationIncrement, y + meshSimplificationIncrement];
meshData.AddTriangle(a, d, c);
meshData.AddTriangle(d, a, b);
}
vertexIndex++;
}
}