PDA

View Full Version : Vertex Arrays, triangle strips, and normals



12-20-2001, 05:01 AM
I am using triangle strips in vertex arrays with averaged normals for each vertex and everything works fine. My question is what is the best way to speed up drawing triangles without averaged normals? What I need to do is be able to switch between drawing a simple terrain with averaged normals and drawing the terrain with normals specified just as the triangle face normal. I draw the triangles with GL_TRIANGLES in a display list with vertex arrays but the speed difference is quite large. Is there another way to speed this up?

Rob The Bloke
12-21-2001, 03:43 AM
Originally posted by Fowler:
What I need to do is be able to switch between drawing a simple terrain with averaged normals and drawing the terrain with normals specified just as the triangle face normal.


glShadeModel( GL_SMOOTH ) -> glShadeModel( GL_FLAT );


Originally posted by Fowler:
I draw the triangles with GL_TRIANGLES in a display list with vertex arrays but the speed difference is quite large. Is there another way to speed this up?

????????????????????????????????????????????
I though you were using triangle strips? why are you using a display list & a vertex array? whats the point? vertex arrays cannot be in display lists - it doesn't work.
????????????????????????????????????????????


Originally posted by Fowler:

Is there another way to speed this up?

yep - use vertex arrays and GL_TRIANGLE_STRIP

Spiral Man
12-21-2001, 08:42 AM
hmm, im drawing triangle strips in a vertex array in a display list, and it works just fine. in fact, the nvidia drivers even appear to be doing some view frustrum culling for me, so ive gotten a noticable speed improvement (as in, twice as fast) when the triangles arent in the view frustrum...

Jambolo
12-21-2001, 12:19 PM
Just a hunch, but try this...

Since the color of a flat-shaded triangle in a triangle-strip is determined by the color of the third vertex, maybe normals work the same way. You would need a separate array for normals since they don't map 1 to 1 with vertices.

12-21-2001, 12:42 PM
I don't know if I was clear or not. I know how to use flat/smooth coloring but this is different then averaging normals to get a smooth lighting effect. If you are using GL_TRIANGLES and specify the normal as the normal perpindicular to each triangle then you get a flat lighting effect, and if you average out all of the normals from each triangle that a vertex connects then you can get a smooth lighting effect, right? But when you use GL_TRIANGLE_STRIP you only get one chance to specify a normal for any vertex. I was wondering if you can get the flat lighting effect somehow faster than using GL_TRIANGLES?

Jambolo
12-22-2001, 11:56 AM
Try my suggestion. If flat-shaded triangle-strip normals work the same as flat-shaded triangle-strip colors, it should work.

If it does, let me know. I want to do exactly what you are trying to do, but I haven't had time to try it.