problems about face normal and vertice normal

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?

as I do not know how to include images in my computer, so I add the image in to the attachment, sorry

184175--6535--$show_161.jpg

No its not (at least not without efforts that are much larger than the 0 effect of having distinct vertices etc)

Without distinct normals for all sides you don’t get lighting edges at their intersections

does it mean that I should provide normal values by myself because unity’s auto calculation is wrong?

As unity can only provide vertice normal (not face normal). So I should calculate the average of the sharing face normals of the vertice?

e.g. suppose the vertice A is shared by triangles a, b, c, d

than normal N(A) = ( N(a) + N(b) + N(c) + N(d) ) /4

is that right? if it’s right, then how does unity do to create such a wrong answer?

The one on the left has the normals averaged, so it appears smooth, the one on the right has a normal for each vertex/face.

As good as it is to have faster mesh calculations (on the left) sometimes it comes at the expense of visual quality.

HTH
AC

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.

thanks, so does it mean

mesh.RecalulateNormals()

does not calculate normals as averaging the sharing faces’s normal on vertice which is the method 3dsmax use? how does RecalulateNormals() implement?

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.

–Eric