# normals and vertex arrays

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

## Recommended Posts

I've just tried for the first time to use vertex arrays and started by rendering a cube. What I'm wondering is, I now have 8 vertices for the cube...how can I compute the normals for them? The "normal" way of rendering a cube is with 6 polygons, 4 vertices each. Then I can set 4 normal for every polygon and that causes some vertices to have several normals. The gourad shading takes care of that, to my understanding, to create somewhat realistic lighting. How does this work when I use vertex arrays and I have only one vertex (and one normal) per corner? How should I calculate the normals to get the same lighting as before? Thanx for any replies

##### Share on other sites
If you're drawing them using indices, to cut down on the number of vertices, then you can't. One normal per vertex does not easily support cubes or angular shapes.

But you can draw all 6 sides by throwing all 24 vertices into the vertex array, then putting your associated normals into your normal array, ignoring an index array, or at least, make your index array point to the correct vertex AND normal comination. Cubes are the worst things to draw with arrays. :)

##### Share on other sites
What I do is create 3 indices for every triangle in my model. Only the vertex xoords are shared, but the UVs and the normals will be different, so technically, they are not the same vertex.

So the size of all my arrays is number of triangles * 3, then glDrawArray can just work through it in order.

##### Share on other sites
Ok, thanx guys for the replies. I thought it was gonna be inefficient in the long run to ignore indices if I use vertex arrays, but then again, I probably won't fill a world with cubes... =)

1. 1
2. 2
Rutin
22
3. 3
4. 4
frob
18
5. 5

• 33
• 13
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
632563
• Total Posts
3007099

×