Archived

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

How to generate Normal averages?

This topic is 6279 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

well, that''s a bit of a math question: i have been trying to find out how to equalize normals of adjacent triangles. in my terrain engine there are always 6 adjacent triangles (naturally), and so i have 1 normal for each triangle. now i want to build the average of those normals and use this normal for the shared vertex. all my tries to generate this normal have failed, but there is bound to be a formula for this, isn''t it? thanks rid

Share this post


Link to post
Share on other sites
Just as you would average integers: add them together and divide
(the length of the vector) by the number of normals. Or you can simply normalize it, because it''s going to be unit-length anyway.

-Jussi

Share this post


Link to post
Share on other sites
hmm, that was the first thing i tried out, and i got only results that couldn''t be right.
probably i am doing something else wrong, i''ll check my code.

thanks anyways
rid

Share this post


Link to post
Share on other sites
You should check if your triangles vertexs are ordered
clock-wise or counter-clock-wise.
if each polygon has its own order, than it MUST be the reason that your avarege normal is screwed up.
By the way, I think that what you are trying to calculate is called "Vertex Normal", but that is only a speculation of mine.

Share this post


Link to post
Share on other sites
shame on me.
i confused the normal and position vectors of my vertices and accidentally added up the position instead of the normals.
now it works perfectly.

it''s always the same, isn''t it?

ps: yes, i am calculating the vertex normals, because if i use polygon normals (i mean three normal for each triangle), gouraud shading looks really crappy

Share this post


Link to post
Share on other sites