View Full Version : Vertex array question
05-14-2002, 07:49 AM
is there a way to use more than one normal per vertex with indexed vertex arrays? If use use an indexed vertex and indexed normal array, when i call draw elements i have to use the same index for both arrays correct? in doing that I loose the ability to call more than one normal per vertex, which is somehting i need to do in order to create Flat surfaces, like surface normals instead of vertex normals. Is there a way around this. As you can tell by my previous posts, i have tried many ways to come up with, but i am serously not getting the right results. any ideas?
Edit: Can more than one normal array be declared? if i could use 2 or three normal arrays per vertex i could get the desired result, but that does intail quite a bit more work on my part. So if any one knows ahead of time, please let me know if that works?
[This message has been edited by dabeav (edited 05-14-2002).]
05-14-2002, 08:23 AM
OpenGL does not have support for normal arrays with more than one normal per vertex. Yeah you have to use the same index for both arrays. If you want flat looking surfaces, just use a surface normal, but you can not use a normal array for it. Specifying more than one vertex normal per vertex is, unless Im missing something, a waste of time. I do not think having more than one array of vertex normals will work because OpenGL will not calculate the lighting for more than one normal, it will just take the last one specified. Just specify a vertex normal per vertex and turn on flat shading.
05-14-2002, 08:33 AM
Thank you for your quick response, i didnt think any of that would work, but i hoped it would. So if I turn on flat shading will that basicaly throw out the normal I have specified, and use what ever one creates a flat surface? Sorry lighting is not my first language. lol.
05-14-2002, 08:57 AM
You only want to specify one normal per vertex, in this case, a vertex normal. Vertex normals are great for smooth shading, but you want your surfaces to look flat, so you just turn on flat shading. This way you can use one array of vertex normals that can be used with your index array. A lot cleaner this way. OpenGL will use whatever normal you specify, you just have to make sure its the right normal!
05-14-2002, 10:02 AM
Ok I think i am asking the right question, in the wrong way, sorry to be so ignorant.
Here is what I have. Vertex array, TexCoord array, Normal array, vert/texcord index, normal index.
The normals are all face normals, because I want the cubes to stay cube looking, aka sharp edges, and the only way to do that is with face normals, not vertex Normals.
Here is what i want to do, use all the above information to create a model, or whatever.
My problem is when I attempt to use the arrays togeather, its going to call 1 normal per vertex, well that wont work if I want things to stay square, which means a corner of a cube, with one vertex normal will create smoothing, not sharp lines, is there ANY way to use vertex arrays with face normals in an array?? It seems like this would have come up at some point if there wasnt any way to do this. But I could be wrong. Will Declaring Flat shading cause opengl to pull out face normals? Or do i not use my Normal array at all, and simply call Flat shading. I dont think that will work, because i have not declared which way the light is up?? Any suggestions. Once again, please excuse my ignorance.
05-14-2002, 10:16 AM
If you really want to use face normals in a vertex array, you can still do it, but you need to duplicate the vertices in the vertex array. Basically, you need to think of a single vertex not just as a position, but as a combination of all the array types you have enabled. So technically, a vertex wouldn't have 2 normals. Instead you would have 2 vertices with the same position, but different normals.
Edit: Just saw your last post...
About flat shading... all that basically does is cause the calculated color of the last vertex of a triangle to be used for the color of the whole triangle. When lighting is enabled, normals are used to calculate the color of that vertex, so just setting flat shading and not giving normals won't work the way you expect. And it won't cause OpenGL to automatically calculate face normals either.
[This message has been edited by Deiussum (edited 05-14-2002).]
05-14-2002, 10:30 AM
Thank you very much for your response but talk about a performance hit, doing it that way will effectivly triple my vertex data. Man I cant believe that OpenGL, as optimized as it is, dosnt have a way to do this cleanly. Alwell, cant do everything right. lol. Once again thanks. If anyone else out there has any great ideas, please share them. Right now i am going to go rewrite my map loading scheme. and them possible, commit harry carry. Thank you. lol
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.