Skip to main content
gamedev.net
🔒 Locked

lighting

Started by martins77 Aug 3, 2006 at 2:25 AM 2 replies 450+ views
Original Post
martins77
martins77
Does anybody knows were can I find a good tutorial about the use of normal vectors in lighting since I’m very confused with the opengl book I’m reading. I have found some sites with a very superficial explanation. For example, how can I calculate the normal of a vertex if the normal belongs to a surface? thanks, MS
deavik
deavik
A good approximation of per vertex normals is averaging the normals of the surfaces which share the vertex. Make each vertex have space for a normal, then do something like this:
for each triangle  get vertices v1, v2, v3  find normal N by cross product (keep the winding order in mind)  add N to the normal of v1, v2, v3for each vertex  normalize the normal

/edit: About understanding how the normals work, draw a surface with normal on a piece of paper and note how the illumination varies with the dot product of the normal and direction of incident light.

Using vertex normals means that the illumination is calculated at each vertex, and the color can be interpolated across the surface of the polygon. This results in smooth (gouraud) shading.
Vexator
Vexator
http://nehe.gamedev.net/

still the best source for opengl newbies :)
Wunderwerk Engine is an OpenGL-based, shader-driven, cross-platform game engine. It is targeted at aspiring game designers who have been kept from realizing their ideas due to lacking programming skills.

blog.wunderwerk-engine.com
martins77
martins77
ok guys, thanks. now I really got the idea.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.