next up previous contents
Next: 7.4 Silhouette Edges Up: 7 Line Rendering Techniques Previous: 7.2.2 glDepthRange   Contents

7.3 Haloed Lines

Haloing lines can make it easier to understand a wireframe drawing. Lines that pass behind other lines stop short a little before passing behind. It makes it clearer which line is in front of the other.

Haloed lines can be drawn using the depth buffer. The technique has two passes. First disable writing to the color buffer; the first pass only updates the depth buffer. Set the line width to be greater than the normal line width you're using. The width you choose will determine the extent of the halos. Render the lines. Now set the line width back to normal, and enable writing to the color buffer. Render the lines again. Each line will be bordered on both sides by a wider ``invisible line'' in the depth buffer. This wider line will mask out other lines as they pass beneath it.

  1. Disable writing to the color buffer.
  2. Enable the depth buffer for writing.
  3. Increase line width.
  4. Render lines.
  5. Restore line width.
  6. Enable writing to the color buffer.
  7. Ensure that depth testing is on, passing on GL_ LEQUAL.
  8. Render lines.

This method will not work where multiple lines with the same depth meet. Instead of connecting, all of the lines will be ``blocked'' by the last wide line drawn. There can also be depth buffer aliasing problems when the wide line $z$ values are changed by another wide line crossing it. This effect becomes more pronounced if the narrow lines are widened to improve image clarity.


% latex2html id marker 7252
\fbox{\begin{tabular}{c}
\vrule width 0pt height 0.1...
...lticolumn{1}{p{5.7in}}{\small Figure \thefigure . Haloed Line}\\
\end{tabular}}

To avoid this problem, use polygon offset to move narrower visible lines in front of the obscuring lines when the lines are being drawn as polygons in line mode. The minimum offset should be used to avoid lines from one surface of the object ``popping through'' the lines of a another surface separated by only a small depth value.

If the vertices of the object's faces are oriented to allow face culling, then face culling can be used to sort the object surfaces and allow a more robust technique: the lines of the object's back faces are drawn, then obscuring wide lines of the front face are drawn, then finally the narrow lines of the front face are drawn. No special depth buffer techniques are needed.

  1. Cull the front faces of the object.
  2. Draw the object as lines.
  3. Cull the back faces of the object.
  4. Draw the object as wide lines in the background color.
  5. Draw the object as lines.

Since the depth buffer isn't needed, there are no depth aliasing problems. The backface culling technique is fast and works well, but is not general. It won't work for multiple obscuring or intersecting objects.


next up previous contents
Next: 7.4 Silhouette Edges Up: 7 Line Rendering Techniques Previous: 7.2.2 glDepthRange   Contents
2001-01-10