- Home /
Procedural mesh, half the faces have wrong normals
I have a script which produces a mesh. It gets an array of (2D) vertices and then just butchers around until the (3D) mesh is done. The Math behind it is really not that complicated, which is why I don't see where I am currently wrong. Here are two screenshots showing my problem:
As you can see, half of the triangles face inwards. I tried generating the triangleIndices differently, so that all are generated clockwise. That didn't do anything though (Although I am 100% sure that it should, I mean, that is how the normals are natively generated, or am I wrong?). Next I called "generateNormals()" for the mesh, still wrong faces. In what you see now, I just gave the first half of the vertices (0, 0, -1) and the second half (0, 0, 1) as normals, which is a horrible way of solving it, bit I thought would at least show them all. But alas, it doesn't.
Before I rewrite all my code to triangleStrip, I wanted to ask if I am doing something obvious wrong.
Answer by ArniBoy · Aug 11, 2013 at 02:28 PM
I stumbled over a thread, and it contained the answer. Just in case anyone finds this and wonders what the answer was, here: http://answers.unity3d.com/questions/187637/procedural-meshs-normals-are-reversed.html
It was what I has suspected, not the vertexnormals are the problem, as they seem to only be used for lighting and such. I am just too bad at writing code, and need to learn how to handle arrays properly.
Cheers, Arne
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Conform mesh to arbitrary surfaces? 3 Answers
What are normals? 1 Answer
duplicate and flip mesh in code 5 Answers
Triangulation for Unity Mesh from Edges 0 Answers