This topic is now archived and is closed to further replies.


Weighted normals leave slight highlights on edges?

Recommended Posts

Anyone got any tips on what could cause this?

//Calculate edge vectors

CVector Edge_01 = m_Vertices[VertexIndices[1]].Point - m_Vertices[VertexIndices[0]].Point;
CVector Edge_12 = m_Vertices[VertexIndices[2]].Point - m_Vertices[VertexIndices[1]].Point;
CVector Edge_20 = m_Vertices[VertexIndices[0]].Point - m_Vertices[VertexIndices[2]].Point;

//Calculate face normal

NewTriangle.FaceNormal = Edge_20.Cross(Edge_01);

//Calculate the angles at each of the corners. (Angles are portions of PI)

float Angles[3];
Angles[0] = ACos(Edge_20.Dot(Edge_01));
Angles[1] = ACos(Edge_01.Dot(Edge_12));
Angles[2] = ACos(Edge_12.Dot(Edge_20));

//Add the normals into the vertices, weighted by corner angle

m_Vertices[VertexIndices[0]].Normal += Angles[0] * NewTriangle.FaceNormal;
m_Vertices[VertexIndices[1]].Normal += Angles[1] * NewTriangle.FaceNormal;
m_Vertices[VertexIndices[2]].Normal += Angles[2] * NewTriangle.FaceNormal;


Share this post

Link to post
Share on other sites
Probably because you haven''t "normalized" the three edge vectors (Edge_01, Edge_12 and Edge_20)

ie , divide each member of the vector (x, y, z) by the total length of the vector, to make a unit vector. This should clear most of it up? Unless you do that already.

I''m not too sure about the final three lines tho. What does the Normal member contain before you add the Angles * NewTriangle.FaceNormal?

Share this post

Link to post
Share on other sites