How to recalculate smooth Mesh Normals like default mesh importer?

I have problems with recalculating smooth normals. I have tried few algorithms but they wasn’t better than default RecalculateNormals() or they simply didn’t work. Maybe there is some way how to access default Model Importer function which calculate normals from normalSmoothingAngle? Or maybe someone knows similar algorithm? :face_with_spiral_eyes:

Why do you need to re-implement this functionality exactly? (It can be done of course, but it can be a little involved, especially if smoothing groups are to be supported.)

i am trying to make simple voxel-based terrain (marching cubes algorithm) and it needs smooth normals. i know that for voxel based terrain there are specific way how to calculate them but i don’t know how to do that. And actually some while ago i was working with procedural meshes and i needed to calculate smooth normals too. So actually i think it could bee quite useful stuff. Probably it is big performance eater but anyways it could be useful.

The general algorithm proceeds as follows:

initialize each vertex normal to the zero vector
for each triangle
    add triangle normal to the vertex normal for each of the triangle's vertices
normalize each vertex normal

Note that if you use unnormalized triangle normals, the vertex normals will be weighted towards triangles with larger area.

For smoothing groups, the general procedure is to identify mesh edges where the angle between the two incident faces is over some threshold, and ‘separate’ the mesh at that edge (that is, duplicate the vertices as needed so that the vertices are no longer shared). Computing the vertex normals then proceeds as described above.

1 Like

Thanks ! :slight_smile:

This saved me:
http://schemingdeveloper.com/2014/10/17/better-method-recalculate-normals-unity/

6 Likes

Hello,

I know, this is a very old post, but I wrote this article that may be useful for many developers even today.
It’s a solution based on this one but extended and with unsmoothing support.

http://threepointsoft.altervista.org/blog/?p=1

6 Likes