glBlendFunc(GL_ONE_MINUS_DST_COLOR,GL_ZERO); with glPolygonMode(GL_FRONT,GL_LINE);

Im having some problems with this specific blending mode causing my wireframe to go semi invisible, its making most of the wireframe invisible while a portion of it is the actual inverse. If my polygon mode is fill it does the correct inverse. And turning off depth testing does not make the wireframe appear. Any ideas?

I am purely guessing here but if your using GL_ONE_MINUS_DST_COLOR then doesn’t it use the “background” colour and subtract it from the each component to give the resulting colour?

You might be getting a different result because with wireframe you can “see” all the way through your object, so this conversion will often be done using your Clear colour - where as you might be using the back faces of your object in FILL mode.

I could be completely wrong though.

Perhaps a link to a screen grab comparing the two might be useful?


Please don’t post an answer when you don’t have one. It’s OK to be mistaken, but here it’s really more than that.

The spec for glBlendFunc() say that the two arguments tell the GL what the scaling factor is for each of the source and the destination fragment; these two values get added to result in a new fragment in the framebuffer. In this case, the formula specified is:

out = in * (1-prev)

I have no idea whether the wireframe behavior is spec compliant or some weird bug; sorry.

This is a weird blend function (no offense intended).

I’m assuming that what you’re doing here is drawing a portion of your geometry on top of itself. I’m assuming further that the color is white (or constant), and that you are using DEPTH_TEST and don’t clear the Z buffer between your original render pass and this “invert” pass. In that casae, you would expect that each pixel covered by your “invert” geometry will be hit exactly once, and the blend function will invert what’s in the frame buffer.

If I’m wrong, too bad…

If I’m right, the problem is probably that for wireframe meshes, each polygon in the mesh will have its complete outline drawn. What that means is that each interior edge is drawn twice. Double inversion! Some of the exterior edges may be drawn only once.

You might be able to use the stencil buffer to make sure that you don’t invert more than once.

Hope this helps.

Wow, that sounds like its exactly it pbrown. It makes perfect sense too, so what i need to do is make a line list for each model to prevent shared edges from rendering the wire twice. Or perhaps some trick with polygon offset and less depth mode might do the trick. Or something with the stencil buffer as you suggest. Thanks I would have never thought of that.

Yup drawing the wireframe overlay with LESS, and line offsetting fixed the problem. Thanks guys.