Sign in to follow this  

normals

This topic is 3293 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey. ive been working on my 3d engine for a while now and it has all the basics (scene graphing, billboarding, its own internal file formats, and a fixed timestep with the display and the game logick runing on separate threads) and ive created some test applications with it including a 3d chess game. Now i want to move on to implementing shaders but before that i guess i have to get lighting to work.. now ive googled up on normals a bit but im strugling to get ahold of something that can realy tell me what i need to do, i understand that i need to load the normals into my VBO's along with my texture coords, vertexes, colours and whatever else but how do actualy calculate the normals? and also whats the difference between vertex normals and surface normals?

Share this post


Link to post
Share on other sites
Each vertex is going to have a normal.
A "surface normal" means that all 3 verts on a triangle have the same normal, the normal of the surface.
A "vertex normal" means that the normal on a vertex is the average of the normals of all triangles that that vertex is part of.

Imagine a pyramid. Surface normals point out from each flat surface on the pyramid. Vertex normals point straight out of each point on pyramid in the direction of that point.

Calculating a surface normal is as easy as taking the cross product of any two edges on that triangle, BUT order maters, so take a stance that counter-clockwise is "out" and clockwise is "in", and calculate all your triangles the same. (but be careful if you are drawing triangle strips, as the winding order changes every-other triangle.

B-D
|\|
A-C

(A-B)cross(C-B) and (B-C)cross(D-C) are your two surface normals.
Also remember to "normalize" your normals.

Share this post


Link to post
Share on other sites
thnx that clears is out for me. fortenetley for me my engine is simple and just duplicates vertexes instead of using the same vertex for 2 triangles so i dont have to worry about different vertex normals on the same surface and also i dont use triangle strips i just draw my triangles with glDrawArray

thnx for the help

Share this post


Link to post
Share on other sites

This topic is 3293 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this