Black lines between neighboring terrains.

Hello. I am having this problem with Unity’s built in Terrain:

These black lines appear when I generate a new neighbor for my terrain and disappear when I get close to them with the camera (doesn’t matter if in edit mode of play mode) - that makes me think is something with updating the lighting. Has anyone encountered this before and have a fix for it? I’m using Unity 2019.3.6f1. Also I tried calling the Flush() method, but it changes nothing.

Yo, today all of the sudden my terrain system started producing the same random black lines on edges of terrain chunks. I generate heightmap procedurally and I found out the issue was caused by weird auto-connecting of neighboring terrain chunks.

Solution

All that was needed was to refresh the internal terrain auto-connecting logic so just paste this code below into a Start or Awake for your terrains:

private void Start()
{
    terrain.allowAutoConnect = false;
    terrain.allowAutoConnect = true;
}