Hi everyone
I have a virus composed of Mesh. There is lighting issue between the mesh
What can of problem is that ? Normals ?
Hi everyone
I have a virus composed of Mesh. There is lighting issue between the mesh
What can of problem is that ? Normals ?
Normals is a good guess ![]()
thanks,
how can i force those normals on the border of my mesh ?
weld the vertices and recalculate the normals.
where did you get this mesh ?
was it generated in unity (from code) or did you got it from an external 3d application (3D Max, Maya, Blender,…)?
Unity community is great as always.
It’s from code. Sorry i’m don’t use to 3d Application and i don’t have the vocabulary. Can i “weld” in Unity ?
Right now i’m setting my vertices and use mesh.RecalculateNormals();
Of course, the mesh don’t know anythings about the other mesh so i understand that the RecalculateNormals() can’t be accurate.
Can i manipulate them manually ?
Also i see i can set up “tangents” is that a good idea ? (i tried to play with it without any effect though)
Welding vertices means combining multiple vertices (preferably vertices that have the same position).
The hard edges you see are there because the triangles there don’t use the same vertices, but rather vertices at the same location but with different normals.
I recently needed to weld vertices in code, and found this script: Dynamically combine verticies that share the same space - Questions & Answers - Unity Discussions (at the bottom of the page).
You best use RecalculateNormals() afterwards.
Tangents are only used for normal maps (bumped shaders and the like) I believe, the tangent of a vertex is based on its normal and UV-coordinates.
I also recently needed to recalculate the tangents of a mesh, and I also found a script for it on the forum, but I can’t find it anymore at the moment.
I think i really get your explanation. Thanks to your reply i now have a better understanding of the situation.
Unfortunately i can’t weld the vertices and use the RecalculateNormals() afterwards. So i will modify the normals after the RecalculateNormals(). I have already done that with fake normals (so all my border share the same normal) Of course it doesn’t give a perfect result but at list the angle have dispeared.
There is one issue though. The lengh of the normal seems to have an impact (while i would have though that only the direction of the normal would have one). Do you know how can i calculate the lenght of the normal ?
Vector3.Normalize() to normalize (make it have a length of 1)
While it’s true that normally only the direction of the normal is important, some calculations with normals assume the length is one, therefore you should always make sure that’s the case.