I am tring to genreate a cube from program, so I make 8 vertices and 12 triangles and use RecalculateNormal to compute the normal for the vertices, however, the result is very ugly(left) and quite different from the cube gameobject created by unity directley(right)
file://c:/show.jpg
seems the left version generates seams at the touching parts of the triangles. I guess it comes from the reason that the cube has only 8 vertices while unity’s cube gameobject has 24 vertices.
However, sharing vertices from different triangles is quite common, especially in models importing from 3dsmax, maya. And not sharing points will enlarge the file size and cost consume.
My question: is it possible to create right lighting effects just as the one of cube gameobject with sharing vertices of different triangles?
unity does nothing wrong, you just provide it with the wrong data.
You expect the right, so provide the right.
You can’t expect to not provide required base data (distinct vertices per side) but still receive the expected output as if you provided those data.
It does exactly what it is meant to do and the result on the left is the correct result for a normal recalculation with only 8 vertices instead of 24.
If you only have 8 vertices you will not get any hard lighting edges independent of what you do.
If you want hard edges, you must seperate the vertices along the edge to be distinct to the triangles on both sides of the edge.
Either you do that in the modelling app (recommend as you have control over it) or you use the import settings to split them
You need 24 vertices if you want hard edges on the cube, no way around it: that’s a 3D hardware thing, not a Unity thing. Yes, you can have fewer using some 3D apps, but they are geared for software rendering and can do things their own way. Even in these apps, any previews you see using 3D hardware are converting the vertices behind the scenes for display purposes.
There’s some muddling of terminology anyway, since normals here are vertex normals, not face normals, and are only used for lighting purposes and have no effect on hard or soft edges. What determines which way a polygon is facing is actually winding order, nothing to do with normals in Unity, and similarly, hard edges always have split vertices, again nothing to do with normals.