Soundbomber's picture

Blending Outlines

Does anyone know of a blending combination that would blend (or antialias) a line with its background but not with other objects in the scene?
I have a number of outlined polygons which, depending on the viewpoint, could all appear aligned behind each other. When this is the case the outlines (when using conventional blending) appear darker than they would if they were not aligned, presumably because each line is being blended with the next.
Anyone any pointers?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Soundbomber's picture

Most of my shapes consist of a couple of closed polygons, separated by a number of lines that link the two together.

Inertia's picture

Some suggestions:

  • GL.PolygonOffset is the right track, assuming the distance between near and far plane is as small as possible.
  • Consider using a FBO with floating-point depth buffer, in my experience this yields much better results than integer depth buffers.
  • Although a hack, you can first draw all solids and then alter GL.DepthRange() and/or the projection matrix' near/far planes before drawing the outlines.
  • GL.Enable( EnableCap.LineSmooth); and the related GL.Hint().
  • Alpha-To-Coverage is an extension to counter aliasing, which sounds like exactly what you need but AFAIK is not available below DX 10 hardware.
  • In addition to drawing the lines, consider drawing points at the vertex positions too. This helps to identify corners under certain rotations and should help avoiding the line loop (the problem with line loops is the primitive restart, which had no cross-vendor solution before GL 3.1).

Hope this helps :)

Soundbomber's picture

Thanks. A couple of new slants on the problem!
Have already tried changing the depth range inbetween drawing the solids and the outline.
Drawing the points is a new one which I will definitely try, am just in the process of implementing the line-loop/line combo and it is turning into more than a few minutes work.
Thanks for the suggestions.