I have some problems with lights calculation when program renders by glVertexPointer and glDrawElements. My model has few polygons with reversed face that’s why I use glLightModel(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE) and everything is OK when program renders vertex by vertex, but when I choose vertex array mode, the problem appears with visible differences between reversed and correct faced polygons. Can anyone tell me what is the reason of it??
when you submit your points in an array they get shared between the triangles.
when a triangle from a trianglelist is rendered, the transformed vertices stay in the cache to be reused by following triangles without new transformations.
when there are two triangles with different winding order sharing a single vertex, in the second triangle this vertex don’t get transformed again…
there are two solutions for your problem:
1.duplicate your vertices so, that every triangle has it’s unique vertex. no shared vertices at all.(as i said ineffective)
render your object in two passes. in the first pass you render backfacing polys only and in the second the frontfacing ones.
Yes, or you could just detect and duplicate the vertice that cause the problem. Unless your model is really messed up, this shouldn’t be to uneffective.
1.duplicate your vertices so, that every triangle has it’s unique vertex. no shared vertices at all.(as i said ineffective)
render your object in two passes. in the first pass you render backfacing polys only and in the second the frontfacing ones.
Hello again
If I understood you correctly I need to know which primitives are reversed in both sollutions!! Is that so??? That’s a little bit complicated because I would have to write a procedure which compare normals or something like this. Besides second sollution with two passes will certainly decrease performance and main goal of vertex arrays is to increase performance !