# Problem when using normal vector in VA

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

## 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 on other sites
Each vertex must have its own normal and positional infomation for Vertex Arrays to work.

If you need to keep hard edges you will need to duplicate the positional infomation at those points and assign each one a correct normal.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634063
• Total Posts
3015309
×