1
\$\begingroup\$

I am programmatically generating terrain using unity's terrain object and assigning height maps to it via the terrainData, the problem is that there are seams even when using the GroupingId(which is used for auto connect). I even tried creating a terrain object in the editor with neighbours, and modified their terrain data via script, seams still there.

I have also tried SetConnectivityDirty after applying terrainData.

Most people who have reported this seemed(lol) to have issues with their normals at the edges, I cant see that being the issue here, but if it is, how do i approach solving it given I am using unity terrains.

If there is no good answer I will have to resort to custom meshes and lose all the nice terrain tool functionality.

enter image description here

Edit: Here is how I'm setting heights.

var terrain = GameObject.Find("test").GetComponent<Terrain>();
var terrainData = terrain.terrainData;
var noiseMap = Tool_Generators.GenerateNoiseMap(chunkSize, seed, scale, octaves, persistance, lacunarity, 0f, 0f);
terrainData.SetHeights(0, 0, noiseMap);

Then the actual noise generation is just a 2D array of heights, i have been using a simplified version with only 1 pass for testing.

  public static float[,] GenerateNoiseMap(int chunkSize, int seed, float scale, int octaves, float persistance, float lacunarity, float offsetX, float offsetY)
  {
    float[,] noiseMap = new float[chunkSize, chunkSize];

    for (int y = 0; y < chunkSize; y++)
    {
        for (int x = 0; x < chunkSize; x++)
        {
            float noiseHeight = 0;

            float sampleX = (x + offsetX) / scale;
            float sampleY = (y + offsetY) / scale;

            noiseHeight = Mathf.PerlinNoise(sampleX, sampleY);
            noiseMap[y, x] = noiseHeight;
        }
    }

    return noiseMap;
  }
\$\endgroup\$
  • \$\begingroup\$ Can you show us how you're creating/assigning your height maps? \$\endgroup\$ – DMGregory Sep 12 '19 at 17:14
  • \$\begingroup\$ what type of image are you using? for best result with height map you have to use RAW format \$\endgroup\$ – virtouso Sep 12 '19 at 17:41
  • \$\begingroup\$ as per the edit, i am creating the height map through code. \$\endgroup\$ – cranial3 Sep 13 '19 at 6:44
  • \$\begingroup\$ It seems that the issue lies somewhere in the fact that the edge folds over slightly, see reddit.com/r/Unity3D/comments/d3w6sb/seamless_terrain for screenshots. \$\endgroup\$ – cranial3 Sep 13 '19 at 21:51

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.