PDA

View Full Version : Normals question



dabeav
03-29-2002, 06:59 AM
I want to create an interleaved array, but my model has multiple normals for each vertex, if I create the array interleaved I can only use one normal per vertex. If I average the normals to find the "middle ground per say" how much lighting quality is lost?? Most of my objects are not going to be boxy, so there will be lots of polys. I dont have to interleave the arrays, but I can really cut down on the number of normal calls if I do. So is it ok to average the normals?? Or is that going to be a HUGE lighting quality hit??

dabeav
03-29-2002, 07:20 AM
Also one more thing, what would be the equation used to average the vertex normals??
some thing like this?
(norm1 + norm2 + norm3)/length(norm1 +norm2 +norm3) if so where does lenght come from?? I found this equation some where, but i have no idea how to find length

zeckensack
03-29-2002, 07:40 AM
Originally posted by dabeav:
Also one more thing, what would be the equation used to average the vertex normals??
some thing like this?
(norm1 + norm2 + norm3)/length(norm1 +norm2 +norm3) if so where does lenght come from?? I found this equation some where, but i have no idea how to find length

That is the correct equation I believe. Length of a vector is defined as the square root of the sum of the squares of the components.



float Vector3::length()
{
return(sqr(x*x+y*y+z*z));
}

zeckensack
03-29-2002, 07:48 AM
Originally posted by dabeav:
I want to create an interleaved array, but my model has multiple normals for each vertex, if I create the array interleaved I can only use one normal per vertex.
That's right. If you want 'multiple normals', you have to duplicate vertices, assign one normal to each copy.

If I average the normals to find the "middle ground per say" how much lighting quality is lost??
Depends on the angle between faces. Obviously, if the normals point almost in opposite directions, your lighting quality will suck after averaging.

I think most modeling packages do it this way:
1)Get angle between two adjacent faces
2)If angle>threshold, duplicate shared vertices, assign distinct normals
3)else, average face normals, assign result to shared vertices

The tricky thing is the threshold to use. It should definitely be less than 90, but you have to experiment. If your threshold is too small, you'll get lots of duplicated vertices and lots of 'flat' triangles too. If it's too large, you'll get bad lighting at sharp edges.

[This message has been edited by zeckensack (edited 03-29-2002).]

dabeav
03-29-2002, 07:55 AM
Thanks alot for the help guys, I think i will use both, I am writting an importation tool, and I will use averaging for models, since they will be mostly curves, and non averaging for maps, since there alot of sharp edges. Thanks...