Skip to main content
gamedev.net
🔒 Locked

Normals & GL_NORMALIZE

Started by robert_s 6 replies 3.8k views
Original Post
robert_s
robert_s
Hi! I did create my first terrain and I am going to add light. Now. In books they say that I should calculate normals myself which increases performance (if properly done). but.. I did a quick search on some OpenGL forums incl. this one and read that I could just simply use GL_NORMALIZE and the whole job of calcluating normals would be done for me by OpenGL. ie no need to calculating normals anymore just add light and thats it! Now! Don''t get me wrong! I am not just trying to avoid that calculation myself! I am just trying to find out if that is true! I thought that GL_NORMALIZE just corrects the normals calculated by me ie. reduces the length of the normal to 1 unit up in case the length is >. I don''t know.. I am confused!.. plz let me know if I am right and say something more about GL_NORMALIZE as to be honest I dont really know how this exactly works! thx!
Fruny
Fruny
From the Blue Book, page 215

GL_NORMALIZE : If enabled, normal vectors specified with glNormal are scaled to unit length after transformation.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
robert_s
robert_s
thats it!
Jackthemeangiant
Jackthemeangiant
You should calculate them yourself. I just made my first terrain engine couple weeks ago, and there is a big preformance differenernce by calculating them yourself over GL_NORMALIZE. I hadn''t leanred the math to do it yet, but I just asked an Algerbra teacher at my school, and it was accualy quiet simple.
robert_s
robert_s
ok! What would be better? - calculating normal per each vertex
on whole terrain or just per each triangle. ie. find a point in the middle of a triangle and calculate the perpendicular (line pointing upwards) to the triangle?
Any ideas! or good hints? Thx!!
Qoy
Qoy
Normals per surface will only give you flat shading. If you want smooth shading (which you probably do) you''ll want to calculate and specify a normal for each vertex. This can be done by averaging the surface normals for the polygons surrounding each specific vertex. The normal for each polygon can be calculated by taking the cross product of two vectors constructed from the vertices of the polygons (in the correct order) and normalizing the result.
robert_s
robert_s
Ok! I see! I need to caclulate normals for my terrain for which I am using GL_SMOOTH as probably everybody does (am I right?) so, that means I should calculate normals per each vertex to have a better terrain appearence(obviously my terrain is not flat)? is that what you're saying Qoy?
I didn't know that you only calculate normals per surface when you have a flat surface! thanks for that! I just want to show you a small image to make sure I understand that all!

Ok! To summarize normal calculation per vertex we should use for curved surfaces and normal calculation per surface we should use for rather flat surfaces. yes? Please correct me if I am wrong with the image or what I am saying! Thanks all!!

Edited by - robert_s on December 2, 2001 8:12:04 AM

Topic Locked

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

Sign in to reply to this topic.