- Home /

# Prevent seams on a generated mesh with split edges.

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:

Here is the code:

```
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;
```

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

How do I combine normals on procedural mesh with multiple tiles? 2 Answers

Mesh generated from bezier curve loop going outside loop 0 Answers

Procedural mesh artifacts. 1 Answer

creating a mesh procedurally 4 Answers

Getting mesh length (x,z) 1 Answer