- Home /
How to invert normals of a geometry generated inside Unity?
Hey guys,
I generated a geometry in Unity and it acts as a wall, but for one of the sides to work correctly, I need to invert the normals.
Somewhere around the internet I was advised to get the normals of the geometry, multiply all of them by -1 and them assign it back to the geometry but this causes no effect whatsoever.
Is there anything I'm missing?
Thank you very much.
Answer by Bunny83 · Feb 02, 2016 at 07:33 PM
What you know as face normals doesn't exist in 3D engines. "Face normals" aren't actual vectors. They just define which side is the visible side. On the GPU this is determined by the winding order of your triangles. In Unity a face need to have clockwise winding in order to be visible. So backfaces have a counterclockwise winding order.
So this:
0----2
| /
| /
| /
|/
1
need to be this:
0----1
| /
| /
| /
|/
2
The vertex normals have no influence on the fact which is the front and which is the back side. Vertex normals are only used by the shader to calculate lighting of the face.
Thanks mate,
I was just trying to do it this way because I searched the internet and some Unity-related page had some info on this, where you had to get the set of normals of the $$anonymous$$esh, invert the vectors and reassign it to the mesh, but it didn't work when I tried it.
Looks like I'll have to narrow down my options to this one, which is setting the triangles clockwise.
Thanks you very much for your time and answer. :)