PDA

View Full Version : Normal Vertex vs. Normal Face



03-16-2001, 07:25 AM
I'm totally green so bare w/ me pls.

You can calculate the normal by using cross products.

p1, p2 and p3 is your three points in space.
v1 is a vector from p1 to p2
v2 is a vector from p1 to p3

n is the normal calculated by using cross product, v1 x v2.
v1.x = p2.x - p1.x
v1.y = p2.y - p1.y
v1.z = p2.z - p1.z

v2.x = p3.x - p1.x
v2.y = p3.y - p1.y
v2.z = p3.z - p1.z

n.x = (v1.y * v2.z) - (v2.y * v1.z)
n.y = (v1.z * v2.x) - (v2.z * v1.x)
n.z = (v1.x * v2.y) - (v2.x * v1.y)

The example above evaluates to the Face Normal, correct?

n is NOT Normalized yet, correct?

To Normalize the Face Nomal, you then sqrt(n.x^2 + n.y^2 + n.z^2), correct?

The Red Book says you need the "Vertex" Normals for lighting to work properly, via glNormal*(). I gather that in order to get the Vertex Normal of a particular Vertex you have to deal w/ all Face Normals that share said Vertex, correct?

This is where i get a little confused. I've read that you must average the "UnNormalized" Face Normals that share said Vertex first, THEN Normalize the averaged Face Normals to get the result glNormal*() needs to work correctly. Is this right?

TIA,
Lee

03-16-2001, 09:06 AM
I first get the Plane normal, then normalize it, and then average the planenormals to get the vertex normal.

And that works just fine with glNormal*(); for me anyway.

DFrey
03-16-2001, 09:58 AM
To get the vertex normal of a vertex, you add the unit normals of the faces that share that vertex and then normalize the result. Another technique is to add weighted face normals instead of unit normals, where the weight for each normal is the area of the face the normal is for, and then of course normalize the result.

[This message has been edited by DFrey (edited 03-16-2001).]

Tim Stirling
03-16-2001, 10:02 AM
Finding the average of the normalised normals( http://www.opengl.org/discussion_boards/ubb/smile.gif ) should work. I never thought there was any other way but now I think about it if you averaged the unnormalised normals then i guess the larger face will produce a larger unnormalised normal and so add a greater effect and so provide a more appropriate average weighted towards the larger face. However, if your faces are the same ( or similar ) size it wont matter. This may be wrong (about what you average first) because I have just made it up now, but it kind of make sense to me!

Tim Stirling
03-16-2001, 10:04 AM
Oh, DFrey you replied just before me, I guess I must be correct then. http://www.opengl.org/discussion_boards/ubb/biggrin.gif

03-16-2001, 01:39 PM
First off, i'm guessing nothing is wrong w/ the way i'm calculating these vertices. Just the order??????? Cuz no one remarked on that part of my post.

I don't mean to point fingers here http://www.opengl.org/discussion_boards/ubb/rolleyes.gif
but, DFrey, you're saying that postit is doing it wrong? I mean, no matter what we do, we are approximating, right? But, whatever gets us closer to "Right" is what we're looking for here. Right? http://www.opengl.org/discussion_boards/ubb/smile.gif BTW, i didnt mean to offend u postit w/ my rolling eyes up there.

DFrey, explain "Weighted" Face Normals a little more in depth. Plug the "Area" into an equation pls.

Ya know, all this is more math related than OpenGL. But hey, i'm gonna ask this anyway. I think that if i understood the the whole concept behind the "Cross Product" thing i would be better off. Any takers? As u might have guessed my math is lacking.

I appreciate all of your posts. Past and post.

Lee

03-16-2001, 01:42 PM
OOO, and if u guys feel froggy, ess plain the Normalizing concept and equation too!!!!