Calculating uv texture coordinates for a procedurally generated circular mesh
I am trying to calculate uv for a grid that I am generating in code. This is a very simple circle (2d)
and I want to texture it like this
and using this code for uvs
uvs[i] = new Vector2((verts[i].x+radius)/(radius), (verts[i].y+radius)/(2*radius));
and the center vertex is (0.5f, 0.5f)
but I am getting a distorted image. (EDIT PHOTO after answer from answer but still stretched out)
Can anyone help here? thanks in advance
+3
source to share