Game Development Reference
In-Depth Information
17.5.3.1 Edge Representation
We represent an edge of a mesh as a quad (built from two triangles)—
see Figure 17.5.
Figure 17.5: A quad to represent an edge
We choose quads for a couple of reasons: We can easily change the
thickness of the edge by adjusting the dimensions of the quad, and we
can render degenerate quads to hide certain edges, namely edges that
are not silhouette edges. In Direct3D we build a quad out of two trian-
gles. A degenerate quad is a quad built from two degenerate triangles. A
degenerate triangle is a triangle with zero area or, in other words, a trian-
gle defined by three vertices that lie on the same line (collinear). If we
pass a degenerate triangle into the rendering pipeline, nothing is dis-
played for that triangle. This is useful because if we wish to hide a
particular triangle we can simply degenerate it without actually remov-
ing it from our triangle list (vertex buffer). Recall that we only want to
display the silhouette edges—not every edge of the mesh.
When we first create an edge, we specify its four vertices so that it
is degenerate (Figure 17.6), which means the edge will be hidden (not
displayed when rendered).
Figure 17.6: Degenerate quad describing the edge
shared by the two triangles
Note that for the two vertices v 0 and v 1 in Figure 17.6, we set their ver-
tex normal vector to the zero vector. Then when we feed the edge
vertices into the vertex shader, the shader will test if a vertex is on a
silhouette edge; if it is, then the vertex shader will offset the vertex
position in the direction of the vertex normal by some scalar. Observe
then that the vertices with a zero normal vector will not be offset.
Search WWH ::




Custom Search