PDA

View Full Version : vertex arrays and light calculations



krol
01-07-2003, 10:28 PM
Hello everybody

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??

Best regards
Marcin Hajder

AdrianD
01-07-2003, 11:47 PM
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)

2. render your object in two passes. in the first pass you render backfacing polys only and in the second the frontfacing ones.

JustHanging
01-08-2003, 12:00 AM
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.

-Ilkka

krol
01-08-2003, 01:17 AM
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)

2. 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 !

thanks for answer
best regards
Marcin Hajder

AdrianD
01-08-2003, 03:24 AM
Originally posted by krol:

If I understood you correctly I need to know which primitives are reversed in both sollutions!! Is that so???


no, in the first solution you only need to copy your vertices.
in the 2nd, you just render them without changing any data !!!

krol
01-08-2003, 10:29 PM
Hello again

These solutions don't seem to be effective enough. Is there any algorithm for correction of reverced faces??

best regards
Marcin