Sign in to follow this  

normals and vertex arrays

This topic is 4073 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

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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... =)

Share this post


Link to post
Share on other sites

This topic is 4073 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