Author Topic: An idea for calculating vertex normals.  (Read 2418 times)

0 Members and 1 Guest are viewing this topic.

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
An idea for calculating vertex normals.
« on: December 22, 2007 »
Something that's annoyed me from time to time is the results of just adding the normals of all triangles that share a vertex and re-normalising, the easiest example is a cube where 2 triangles on 1 or 2 of the faces share a vertex and the other face(s) only have 1 triangle using the vertex, the normals end up a bit off.

so I've come up with a solution, for that case at least as I'm not 100% sure what the results will be like in other cases and I'm a little busy right now to try anything out.

Code: [Select]
vector_sum += triangle_normal * acos( dot(v0,v1) )  'where v0 and v1 are unit vectors
                                                    'pointing away from the vertex along
                                                    'the 2 edges of the triangle

Anyway, if you've come up against this problem this might be of some use and if you find this is good or bad in other cases let me know.

Cheers, Fryer.
« Last Edit: December 22, 2007 by Stonemonkey »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: An idea for calculating vertex normals.
« Reply #1 on: December 22, 2007 »
Cool idea!  It means that instead of blindly adding all the normals of the faces that share a vertex, what you do is take in to account the shape of the polygons and how much 'influence' they have on the vertex.
K+
Jim
Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: An idea for calculating vertex normals.
« Reply #2 on: December 22, 2007 »
Yep Jim, I was imagining the normal at the shared point on a triangle fan with all triangles on the same plane, the amount of that planes normal that's added will always be the same no matter how many triangles the fan is divided into as long as the extreme edges are constant or keep the same angle between them.