Jump to content
  • Advertisement


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


Weighted normals leave slight highlights on edges?

This topic is 6383 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!