I am trying to calculate the uv's for a mesh I generate in code. It's a very simple circle (2d)
and I want to texture it like follows
and using this code for the 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 help from answer but still stretched)
could anyone help here? Thanks in advance
How about this:
Lets assume that the coordinates of the center vertex are (centerX, centerY)
uvs[i] = new Vector2(0.5f +(verts[i].x-centerX)/(2*radius),
0.5f + (verts[i].y-centerY)/(2*radius));