i
i
i
i
i
i
i
i
11.4. Lines 527
11.4 Lines
Rendering of simple lines is often considered relatively uninteresting. How-
ever, they are important in fields such as CAD for seeing the underlying
model facets and discerning the object’s shape. They are also useful in
highlighting a selected object and in areas such as technical illustration. In
addition, some of the techniques involved are applicable to other problems.
We cover a few useful techniques here; more are covered by McReynolds
and Blythe [849]. Antialiased lines are briefly discussed in Section 5.6.2.
11.4.1 Edge Highlighting
Edge highlighting is a fixed-view technique useful for rapid interaction with
large models (see Section 10.2). To highlight an object, we draw its edges
in a different color, without having to redraw the whole scene. This is an
extremely fast form of highlighting, since no polygons are rendered. For
example, imagine a blue polygon with gray edges. As the cursor passes
over the polygon, we highlight it by drawing the edges in red, then drawing
gray edges again when the cursor leaves. Since the view is not moving,
the whole scene never has to be redrawn; only the red highlight edges are
drawn on top of the existing image. The idea is that the original gray
edges were drawn properly, so that when a red edge is drawn using the
same geometric description, it should perfectly replace the gray edge.
11.4.2 Polygon Edge Rendering
Correctly rendering edges on top of filled polygons is more difficult than it
first appears. If a line is at exactly the same location as a polygon, how do
we ensure that the line is always rendered in front? One simple solution
is to render all lines with a fixed bias [545]. That is, each line is rendered
slightly closer than it should truly be, so that it will be above the surface.
In practice, the underlying polygon is usually biased away from the viewer.
This works much of the time, but there are problems with this naive
approach. For example, Figure 6.26 on page 185 shows a torus that has
some edge dropouts due to biasing problems. If the fixed bias is too large,
parts of edges that should be hidden appear, spoiling the effect. If polygons
are near edge-on to the viewer, a fixed bias is not enough. Current APIs
provide a separate factor that makes the bias also vary with the slope of the
polygon rendered, thereby helping avoid this particular problem. If API
support is not available, other techniques include changing the projection
matrix: The viewport near and far values could be adjusted [833], or the
z-scale factor could be modified directly [758, 833]. These techniques can
often require hand adjustment to look good.