PDA

View Full Version : vertex normals

07-10-2003, 02:42 AM
Hi, I want to use a Normal for each Point of my scene. Does anyone know how to calculate them? I've just worked with Normals for each Triangle, but that's not what I want ...
THANX

Tea
07-10-2003, 03:03 AM
Well actualy what is the good of those vertex normals , explain for beginner please..

mikael_aronsson
07-10-2003, 03:04 AM
Hi !

There are a number of ways to cheat, but still look's ok, have a look at the Graphics Gems code to have a look on how it can be done, there is an example of code that calculates the vertex normals for a mesh of polygons.

Google should also give you a good set of hits.

Mikael

mikael_aronsson
07-10-2003, 03:08 AM
Originally posted by Tea:
Well actualy what is the good of those vertex normals , explain for beginner please..

Hi !

If you have a sphere for example and just use surface normals (all vertex normals point in the same direction), you get a pretty ugly sphere (unless that's what you want) because you can see each triangle the sphere is built from.

If you calculate vertex normals you get a smooth sphere (or at least it look's smooth to som extent). because it makes the colors behave like the triangle is a curved surface.

You do this by modifing the vertex normals to average between the triangles that use that vertex.

Mikael

07-10-2003, 03:57 AM
Originally posted by mikael_aronsson:
Hi !

If you have a sphere for example and just use surface normals (all vertex normals point in the same direction), you get a pretty ugly sphere (unless that's what you want) because you can see each triangle the sphere is built from.

If you calculate vertex normals you get a smooth sphere (or at least it look's smooth to som extent). because it makes the colors behave like the triangle is a curved surface.

You do this by modifing the vertex normals to average between the triangles that use that vertex.

Mikael

Good example. But this not useful for objects like walls, floors(couse of their low count triangles).

billy
07-10-2003, 04:41 AM
First you should have an ordered structure of your geometric data. I used half-edge data-structure: www.flipcode.com/tutorials/tut_halfedge.shtml (http://www.flipcode.com/tutorials/tut_halfedge.shtml)

After that just loop around each vertex, add all the normals of the adjacent polygons and then normalize it.