1
\$\begingroup\$

I have been generating procedural terrain for an upcoming project however I am coming across a seaming effect between the tiles:

Seaming Effect

I have searched for solutions including this video.

Here is the code (sorry for the lack of comments):

chunkx and chunky are the x and y coordinates of the chunk that is being generated.

seed is a randomly generated integer.

float Gen_Height(int x, int y, int seed)
{
    float height = 0;
    float newx;
    float newy;
    for (float resolution = 128; resolution >= 8; resolution /= 8)
    {
        newx = (seed / 40f) / resolution + x / resolution;
        newy = (seed / 40f) / resolution + y / resolution;
        height += (Mathf.PerlinNoise(newx, newy) - 0.5f) * resolution;
    }
    if (height < 0) height = 0;
    return height;
}

public List<Vector3> Gen_Vertices(int chunkx, int chunky, int seed)
{
    float height;
    int x = 101;
    List<Vector3> vertices = new List<Vector3>();

    for (int i = 0; i < x; i++)
    {
        for (int j = 0; j < x; j++)
        {
            height = Gen_Height(i + chunkx * (int)x, j + chunky * (int)x, seed) * heightmod;
            vertices.Add(new Vector3(2*i, height,2* j));
            if (height > maxheight) maxheight = height;
            else if (height < minheight) minheight = height;
        }
    }
    return vertices;
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.