Custom mesh and normals?

Hi,



I wrote some code too import a level from a file generated with an external level editor. I use the data in the file too generate a custom mesh. The level itself is loaded beautifully, but I can’t get the normals too work. I tried setting the normal too the correct value every time I add a polygon too the mesh, but this left me with a striped pink and bleu mesh (in the showNormals material) instaed of faces with the same direction having the same color every time. This told me that the normals might be per-vertex instaed of per-polygon, but most of the vertices have multiple faces attached too them, in such a way that interpolating the normals of the faces attached to each vertex would in most cases give the zero vector.



Is there a way to generate correct normals for the mesh?



Many thanks in advance.

Afaik it should be relative to the polygon, so just putting all to unity-y should work?

putting all to unity_y just does the same as not setting normals at all (which means mostly grey, with some random spots of blue, pink and white).

If your normals are per polygon and you are sharing vertexes then you will have to duplicate them so that each vertex can have the appropriate normal.