About normals and light

Hello guys,

I’m trying to do a model renderer, I have a model, described in slices, and I already know and have the faces calculation working, so now, I wnat to know how to calculate the normals to perform lighthing, is better to use normals per vertex or normals per face ? Can someone show me how do I calculate both, and another thing is, how to make good light positioning, does it have some especial way to perform and calculate the values of the direction, and the materials value ? Sorry if I am making mistakes, I’m new to light stuff.

Thank you for the moment
BST RGDS

Kurt

per face normal:
if v0, v1, v2 are the vertices of a face (counterclockwise), create 2 vectors d1 = v1 - v0 and d2 = v2 - v0, make the cross-product of d1 and d2 which gives you a vector perpendicular to the face, normalize the result and you have a normal
per vertex normal: http://www.xmission.com/~nate/smooth.html

is it better to use normals per vertex or normals per face ?

Well, that depends on what you want your model to look like. If you use one normal for each face, you’ll get flat-shaded facets. If you use one normal per vertex, you get smooth shading as it interpolates over the face.

Remember that OpenGL basically expects a normal for each vertex, so you won’t really save any effort or speed or memory by using one normal per face…