# Prevent seams on a generated mesh with split edges. [Unsolved]

I asked this question on Unity Answers but there hasn’t been a single answer, so I’m posting it here:

I’ve got a script that generates a procedural mesh and then splits the edges to make it flat shaded, but there’s a problem when viewing it.

There are these seams that are visible at the edges, and when viewed from a distance, cluster together to make a white/yellow hue on the entire mesh.

Here are some pictures:

``````Mesh mesh = meshFilter.mesh;
Vector3[] vertices = mesh.vertices;

for (int i = 0; i < vertices.Length; i++) {
float xCoord = Mathf.Abs((transform.position.x + vertices[i].x) * scale)-5000;
float yCoord = Mathf.Abs((transform.position.z + vertices[i].z) * scale)-5000;
vertices[i].y = (Mathf.PerlinNoise (xCoord, yCoord) - 0.5f) * power;
}
meshFilter.mesh.vertices = vertices;
meshFilter.mesh.RecalculateBounds ();
meshFilter.mesh.RecalculateNormals ();

// split edges
Vector3[] oldVerts = vertices;
int[] triangles = mesh.triangles;
vertices = new Vector3[triangles.Length];
for (int i = 0; i < triangles.Length; i++) {
vertices[i] = oldVerts[triangles[i]];
triangles[i] = i;
}
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.RecalculateBounds();
mesh.RecalculateNormals();

meshFilter.mesh = mesh;
meshCollider.sharedMesh = mesh;
``````

I’ve searched through existing questions for quite a while, and I haven’t found anything.

I think you’re going to have better luck by trying different shaders, rather than looking in the script.

Thing is, I haven’t really touched shaders too much, and I wouldn’t have any idea on where to begin. When I looked up this problem, I came across this link and it explains why it happens (I think it’s the same in Unity), but I still don’t know how to prevent this.

I think that link is describing a different issue. It’s actually describing the opposite of the effect you want, if I’m reading it correctly; it’s describing how to make smooth boundaries between polys, while you’re wanting the jagged low-poly look.

I’m not good with shaders either, but I still think your best bet at an easy fix here is just to start choosing different shaders at random and hope that there’s one that doesn’t exhibit this problem but still has the look you are going for.

OK, I just went through all the shaders I had in my project, but sadly nothing worked.

Are you sure the green lines you are seeing arn’t isn’t just the MeshCollider gui?

Disable the meshcollider, or turn off gizmos at run-time.

Those screenshots were from in-game, and the collider lines would have been on the actual faces themselves.

I just took that script and added it to a scene myself. Everything looks perfect on my end.

The problem must be somewhere other than this code.