Haha, im getting confused more and more
so here goes the context:
I’m creating a tilemap. At first i used shared vertices, then i switched to unique vertices to be able to be able to map tiles from an atlas on to the tiles individually.
I don’t need this uv mapping anymore - but im dynamically creating submeshes, if a tile changed. Now my question was, if i still need unique vertices for this or if can fall back to shared. From my understanding it should work with shared ones - but i didnt want to corrupt my code just for testing purpose at this point - so i asked.
I do it like this for each quad i’m iterating through:
Vector3[] getVertices(Vector3 pos) {
Vector3[] v = new Vector3[4] {
new Vector3 (pos.x , pos.y , pos.z),
new Vector3 (pos.x + _tileSize , pos.y , pos.z),
new Vector3 (pos.x , pos.y , pos.z + _tileSize),
new Vector3 (pos.x + _tileSize , pos.y , pos.z + _tileSize)
};
return v;
}
Vector3[] getNormals() {
Vector3[] n = new Vector3[4] {
Vector3.up,
Vector3.up,
Vector3.up,
Vector3.up
};
return n;
}
Vector2[] getUVS() {
Vector2[] u = new Vector2[4] {
new Vector2(0, 0),
new Vector2(1, 0),
new Vector2(0, 1),
new Vector2(1, 1)
};
return u;
}
int[] getTriangles(int cnt) {
int[] t = new int[6] {
cnt + 0,
cnt + 2,
cnt + 1,
cnt + 2,
cnt + 3,
cnt + 1
};
return t;
}
So, wouldnt submeshes also work if i gave back the 2 vetices of the last quad and add the 2 new ones?
The reason for this question wasn’t the point to possibly get rid of some unnecessary vertices, which would be ok if possible, but the fact that when i deform my mesh: set some vertices higher or lower: the unique vertices approach breaks up my mesh. So when deforming the mesh i’d need to also move the vertice of the neighbouring tile with the “same” but each unique Vector3.