- Home /
scripted mesh lighting problem (and uv question)
Greetings, I've written a script to create a 2D oval shape as a mesh. Vertices, normals, uv, triangles, all is set. The Shape is getting generated and visualized correctly. With the exception of recieving shadows. No clue what I'm missing pls help me out! :(
Also: how do I set the uv for my border right? At the moment the oval get generated like 'center vertex' + 'rotated vertices along radius' + 'rotated vertices along border'. Then I generated two set of triangles and set them to different submesh indices of the final mesh. Submesh '0' is the inner fill of the oval, and submesh '1' is the border.
uv for the vertices is generated very simple at the moment. I probably require more vertices (double border) to make the uv for the border working. but I'm not sure so I thought I should ask.
To the lighting:
Demo: https://www.youtube.com/watch?v=a8Ez8bq9nBM
(debug view and inspector)
To the uv:
(rvertices = rotated vertices along radius, so the verts along border get the same uv as the verts along the radius.)
verts[0] = Vector3.zero;
normals[0] = Vector3.back;
uv[0] = new Vector2(0.5f, 0.5f);
for (int i = 1; i < vertices; i++) {
verts[i] = this.Vertices[i];
normals[i] = Vector3.back;
if (i < rvertices + 1) uv[i] = new Vector2(0.5f + (Vertices[i].x / (Radius * 2)), 0.5f + (Vertices[i].y / (Radius * 2)));
else uv[i] = new Vector2(0.5f + (Vertices[i-rvertices].x / (Radius * 2)), 0.5f + (Vertices[i-rvertices].y / (Radius * 2)));
}
(just a dice to test uv, border uv not right yet)