• Welcome to Dark Bit Factory & Gravity.
 

An idea for calculating vertex normals.

Started by Stonemonkey, December 22, 2007

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Stonemonkey

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.


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.

Jim

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:

Stonemonkey

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.