Triangle strip with a LINE triangle display error

I’m trying to draw a cartoon shaded model with black outline. I learn one method to draw the outline by first drawing the model as usual, then draw the model again with FRONT FACE CULLED and draw back face strip with thick wireframe. However, there is a display problem!

The model is consist of a number of strip polygon, some strip will U-turn from its current direction, that produce a SINGLE LINE triangle. This front facing single line triangle will be displayed as a line during back face drawing.

Do anyone know why it is shown? I am sure that this drawing is working (no line showing) before, however, after several months of other codes modification, the line appear incorrectly.

I cannot trace back if some modification made causing this problem (as there are huge number of modifications), do anyone know the cause?

glPolygonOffset maybe?

I don’t think so.
I think the problem is: how opengl determine this LINE triangle’s facing direction (normal vector). Actually only plane has normal, but a line doesn’t.

May be I have ENABLE something that let opengl draw such LINE triangle, which shouldn’t be drawn as usual, since at the begining of my outline code, it is working fine.

Can you post a screenshot of your problem? It would really help.

You should use glPolygonOffset.

how do the glPolygonOffset helP?
Actually, the line shouldn’t be drawn.
Secondly, I have tried glPolygonOffset to hide this line on the polygon, need to set offset to 10000.0f in order to hide the when looking close to the model, it remove the line perfectly. However, while we zoom out, the needed OUTLINE of the model will be disappear due to the glPolygonOffset.

I think the mean problem is not glPolygonOffset usage, I want to know the REASON why the line appear? It will not be shown before without any glPolygonOffset.

Anyone can help?

how about a screenshot? my magic orb isn’t working.

GL detects front facing based on triangle winding after projection. Winding could be clock-wise (CW) or counter clock-wise (CCW). It up to you to choose which one will be front or back. But be carefull when you building your own meshes… all triangles MUST have same winding. Otherwise, if you enable culling you might have problems with missing polygons.

Yes, I know about CW and CCW of the triangle. The winding of the LINE-triangle is correct. The winding will generate a normal on the plane, however, what will be the normal of a LINE-triangle? Then, how opengl determine it is facing forward or backward of this LINE?

As soon as I prepared the images, it will post them here.

I attached two images, showing the problem LINE-Triangle.
The second one is just the back-faced wire-frame.

Looks like z-fighting… can you tell us your camera near and far values… or even better, how do you set up projection matrix?

Why do you think it is Z-fighting? I haven’t the program on hand right now, but I remember the near should be around 1 and far should be about 300.

Do you think the collinear triangle should be draw? Should openGL refuse the draw such kind of triangle by default?

Actually I have tried a D3D program, such collinear triangle will not be drawn. It is strange that it work before (no such black on the front polygon), after a lot of program change, it failed to work. :eek:

is it that only the outline should be visible? it looks like you don’t disable front face culling while rendering the lines.

Of course not!
If I still have the front polygon drawing, you should see more line on the character. But there is LINE (not triangle) on the face, those two red lines I have marked, is just an example. In fact, in the wireframe image, you should notice some more LINE, they are collinear triangle.

You mean “degenerate” triangles.
Those can not be backface-culled, as back face culling works by testing the order of vertices on screen, either clockwise or counter-clockwise (and NOT by testing normals !). If 2 or 3 vertices of a triangle are at the same place, it is not possible to know if it is CW or CCW.
This is not a problem for filled triangles, as these degenerates are guaranteed to not produce any pixel fragment.

I am pretty sure the best solution is cleaning the model geometry.

i don’t get it. do you draw it with lines or do you draw it with triangles and polygonmode GL_LINE? reading above sounds like the second one. you can notice on the wireframe picture that there just lines pointing into nowhere. i agree with ZBuffeR then, cleaning up geometry and see what happens.

btw. in second picture i see a single triangle in top-right corner?

I know that to solve the “degenerate” triangle is to clean up the model. The engine provided me a function to convert STRIP mode to TRIANGLE mode, those special LINE disappear! But the render performance is too low, too. The engine’s 3DSMAX exporter will generate strip for series of triangles automatically, including several reversals (must generate a “degenerate” triangle when reverse).

Actually, my question, from the start of this thread, is that, those LINE is not appearing BEFORE, but I am not sure what program has been changed and these LINE appear out of my expectation. I tried to use D3D, simulating the same situation, there is no LINE appear. So I think opengl will be the same to reject those “degenerate” or “collinear” triangle.

Do anyone know, what status (glEnable or something else) can let openGL accepting those “degenerate” or “collinear” triangle? That’s actually my question.

The model is consist of some numbers of STRIP (so I use STRIP to render). Firstly, I render them as normal, with back face cull, FILL mode. Secondly, I render them again, but with front face cull, LINE mode, line width 4. Just a simple drawing, we can get a cartoon style outline around the character’s edge.

The code has be implemented several months ago and it working well. In these past few months, I have made a lot of change to other part of the program, and when I tried this outline effect again, those lines appear out of my expectation!

That’s why I have this question.

Can you try code with simple model… like box or teapot?