PDA

View Full Version : accumulator and incostent winding



yakovm
04-01-2010, 12:09 PM
I have a mesh in which not all surfaces are winded consistently in same direction also I don't know the direction of any face if it is CW or CCW .In order to solve the problem I use accumulator buffer and two side lighting one time with false and then save it to accumulator and second time with "true" and send it to accumulator too. And finally return from it
(I use following commands
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE
glAccum(GL_ACCUM
)
What you do think? What the possible pitfalls could be?

ZbuffeR
04-01-2010, 01:02 PM
What about just disabling backface culing ?

yakovm
04-01-2010, 01:30 PM
I am trying to use culling but It seem it didn't work
what do you think


glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glCullFace(GL_FRONT);
glMaterialfv(GL_BACK, GL_DIFFUSE,matCol);
//render here .....(back faces)
glCullFace(GL_BACK);
glMaterialfv(GL_FRONT, GL_DIFFUSE,matCol);
//render her..(front faces)

ZbuffeR
04-01-2010, 01:56 PM
What meant :
glDisable(GL_CULL_FACE);
then draw only once your model.

yakovm
04-01-2010, 02:09 PM
You didn`t undersrand the problem:
part of the normals are directed incorrectly.(And I don`t know
which of them)I need to use two-sided lighting model to render these faces and(concurrently) render other (with correctly defined normals) in the regular way.

ZbuffeR
04-01-2010, 02:48 PM
No, I do think I understood your problem, at least if normals and CCW/CW winding order are consistent one with the other, even if not across the model.

Please follow my explanations, and at least try to implement them :
1) - front facing/back facing is determined according to CCW or CW winding order, and allow OpenGL to decide is face is culled or not when back (or front) face culling is enabled
2) - *so that means you need to disable backface culling*
3) - only the normal direction is used to compute lighting
4) - two-sided lighting, when enabled, reverses the normal for back faces (when detected according to 1) and leaves alone normals of front facing triangles.
5) - *so you need 2 sided lighting too*
6) - *and nothing else*

Can you share a picture of this rendering with your data ?

But let me say that if you have to possibility to clean your models before rendering, it would provide you better performance.
Not in the case of completely dynamic geometry, alas.

Can you share how comes you get unclean geometry ? Is that dynamically generated, user generated , ... ?

ZbuffeR
04-02-2010, 07:38 AM
Are you positive that winding order and normals are always consistent one with the other ?
How are the normals created ?

zeoverlord
04-02-2010, 01:50 PM
You didn`t undersrand the problem:
part of the normals are directed incorrectly.(And I don`t know
which of them)I need to use two-sided lighting model to render these faces and(concurrently) render other (with correctly defined normals) in the regular way.


Two side lighting is not a fix for bad geometry, try and get it right first, if you cant do it in a modeler then run the geometry trough some algorithms to fix it.