Archived

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

Averaging Normals

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

Is averaging normals as simple as grabing the vertices adjacent normals and dividing them by the amount you grab? Like: A B C D V E F G H V is my normal to be averaged, and ABCDEFGH are the adjacent ones, would the eq be: V = (A+B+C+D+E+F+G+H)/8;

Share this post


Link to post
Share on other sites
Wouldn't it be enough to only take the average of BDEG?
Your vertices are probably:
a--b--c
|``|``|
d--v--e
|``|``|
f--g--h
so I think it could be enough and a bit faster. Just an idea.
Do you get worse quality?


Click NOW!

[edited by - SwSh on November 18, 2002 1:31:04 PM]

Share this post


Link to post
Share on other sites
Renormalizing the normals didn''t seem to change the visible aspect of the terrain at all. Are you sure I need to this? I mean, if the 9 normals are already normalized, when I divide the sum of them all it won''t ever be >1.0. I may be commiting a mistake.

SwSh: More normals you grab, more smooth the lighting will be Also, the normals are generated when I load up the terrain, so, I don''t really need to get small speed boosts (or even <2 secs speed boosts).

Share this post


Link to post
Share on other sites
quote:

Renormalizing the normals didn''t seem to change the visible aspect of the terrain at all. Are you sure I need to this? I mean, if the 9 normals are already normalized, when I divide the sum of them all it won''t ever be >1.0.


It''s needed. Normal vectors do not behave correctly, when linearly interpolated or weighted. The direction will be correct, but the magnitude won''t.

Consider this simple example, where you compute the average of two normals:

((0,1,0) + (1,0,0)) / 2 = (0.5, 0.5, 0)

The resulting vector is denormalized (should be: (~0.71, ~0.71, 0))

If you have a very smooth terrain, then the artifacts aren''t necessarily directly visible. It doesn''t change the fact, that your normals will be wrong. This will create very weird effects, if later on you include perpixel lights, collision detection, etc.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:

Wouldn''t it be enough to only take the average of BDEG?
Your vertices are probably:
a--b--c
|``|``|
d--v--e
|``|``|
f--g--h
so I think it could be enough and a bit faster. Just an idea.
Do you get worse quality?
[/Quote]

What you can do is take a weighted average. Give more influence to B,D,E, and G and less to the rest. So you can say

V = ( 0.1875 * B + 0.1875 * D + 0.1875 * E + 0.1875 * G +
0.0625 * A + 0.0625 * C + 0.0625 * F + 0.0625 * H) / 8

FYI, yes all those numbers add up to 1. What this does is that 75% of the average came from the adjacent normals, and 25% came from the diagonal ones

Share this post


Link to post
Share on other sites