Hi,

I’m experimenting with procedurally generated grids, and I’m trying to find a way in which I can split the vertices, that way no vertices are shared between two triangles. This should be able to give me ‘sharp’ edges in my mesh.

The problem is, I can’t seem to figure out how to do that. I’m pretty new to mesh generation, and if anyone can point me to the right direction that’ll be great!

```
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class TGen : MonoBehaviour {
private Mesh mesh;
private void OnEnable () {
if (mesh == null) {
mesh = new Mesh();
mesh.name = "Surface Mesh";
GetComponent<MeshFilter>().mesh = mesh;
}
Refresh();
}
public void Refresh () {
CreateGrid();
}
private void CreateGrid () {
Vector3[] vertices = new Vector3[(33 + 1) * (33 + 1)];
Vector2[] uv = new Vector2[vertices.Length];
float stepSize = 1f / 33;
for (int v = 0, y = 0; y <= 33; y++) {
for (int x = 0; x <= 33; x++, v++) {
vertices[v] = new Vector3(x * stepSize - 0.5f, y * stepSize - 0.5f);
uv[v] = new Vector2(x * stepSize, y * stepSize);
}
}
mesh.vertices = vertices;
mesh.triangles = new int[] {
0, 2, 1,
1, 2, 3
};
int[] triangles = new int[33 * 33 * 6];
for (int t = 0, v = 0, y = 0; y < 33; y++, v++) {
for (int x = 0; x < 33; x++, v++, t += 6) {
triangles[t] = v;
triangles[t + 1] = v + 33 + 1;
triangles[t + 2] = v + 1;
triangles[t + 3] = v + 1;
triangles[t + 4] = v + 33 + 1;
triangles[t + 5] = v + 33 + 2;
}
}
mesh.triangles = triangles;
}
}
```