Sign in to follow this  

Problem when using normal vector in VA

Recommended Posts

Hello all! I'm tackling with vertex array for rendering my models in my engine. But i have a trouble on using normal vector in VA. The number of vertices is not equal to that of normal vectors in my model. I think it is not a bizzare thing! When we calculate a smooth normal for a vertex, we don't want to average the facet normals of all the polygons that the vertex is in if there are edges that are to be preserved in the model. So one vertex may have different normal vectors in different polygons that the vertex is in, which result in the number of the normal vectors is often not equal to the number of vertices. The problem is, since the size of vertex array and normal array is not equal, how can i index them simultaneously with one indice array in the glDrawElements call? glDrawElements( GL_TRIANGLES, nTriangles, GL_UNSIGNED_SHORT, indices_array); The array indices_array packs vertex indices of each triangle, for instance, three vertex indices of the first triangle are stored in indices_array[0]=1,indices_array[1]=2,and indices_array[2]=5, but the 1st, 2nd, or 5th elements in normal array may not exactly be the three vertex normals of the first triangle! Because there's no guarantee that one vertex has only one normal vector in the normal array at the same location as the vertex array. I'm not sure if i have expressed my problem clearly! Excuse me that I'm not a native speaker:) Any helps or advices appreciated! Thanks in advance!

Share this post

Link to post
Share on other sites

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