Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: Normals question

  1. #1
    Member Regular Contributor
    Join Date
    Sep 2001
    Location
    macedon, ny
    Posts
    289

    Normals question

    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??

  2. #2
    Member Regular Contributor
    Join Date
    Sep 2001
    Location
    macedon, ny
    Posts
    289

    Re: Normals question

    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

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,652

    Re: Normals question

    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.

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

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,652

    Re: Normals question

    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).]

  5. #5
    Member Regular Contributor
    Join Date
    Sep 2001
    Location
    macedon, ny
    Posts
    289

    Re: Normals question

    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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •