Averaging normals


You have to learn the linear algebra to calculate the normals.


NORMAL result = 0;

for(i = 0; i < number of normals; i++)
result += normal[i];

normal /= number of normals;


The above code needs to have the line:
“normal /= number of normals” replaced with normal.normalize().

This is because, for instance, if one normal is 0,0,1 and another is 0,1,0 you would get 0,0.5,0.5 as the answer which is not unit length.

– Zeno

Is it…

NORMAL result = 0;

for(i = 0; i < total_of_normals; i++)
result += normal[i];

normal /= total_of_normals;

You don’t have to divide by the number of normals at all. Just sum them and normalize the resulting vector.