## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

291
Concepts and Examples
The geometry shader is a new capability in shaders, introduced in late 2006
with the release of Shader Model 4 to take advantage of the ever-growing
capability of high-end graphics cards. It adds to the programmer’s graphics
capabilities by providing tools to expand the basic model geometry to include
more or dierent graphics primitives than were initially dened. Thus, geom-
etry shaders should really be called “geometry creators” or “geometry expand-
ers.” The place of the geometry shader in the graphics pipeline is shown in Fig-
ure 12.1, where “vertex processing” can include a vertex shader, tessellation
The geometry expansion that is provided by the geometry shader has
many uses. One is in using the input geometry to create additional geome-
try, such as silhouee edges, shrunk triangles, or hedgehog plots. Another is
in managing level of detail (LOD). The LOD, shrunk triangles, and silhouee
edges examples are discussed later in this chapter, and hedgehog plots are
discussed in Chapter 15.
12
292
12. Geometry Shader Concepts and Examples
What Does the Geometry Shader Do?
erate all the familiar topology types plus a few new ones that we will cover
below:
Points.
Lines.
Line strips.
Line loops.
Triangles.
Triangle strips.
Figure 12.1. The geometry shader in the graphics pipeline.
293
What Does the Geometry Shader Do?
Triangle fans.
Any of these topologies can be used by
the application, but geometry shaders have
a limited number of topologies that they can
accept. These are points, lines, lines with
cency.
Thus, the primitives used by the appli-
cation sometimes need to be internally con-
On the output side, the geometry shader then generates points, line strips,
or triangle strips, and feeds them on to the rest of the graphics pipeline.
There needn’t be any correlation between geometry shader input type
and geometry shader output type. Points can generate triangles, triangles
can generate triangle strips, and so on. In the silhouee example later on in
this chapter, the input is the new “triangles with adjacency” graphics primi-
tive, while the output is simply lines. This is described more visually in Fig-
ure 12.2.
Figure 12.2. The kinds of processing geometry shaders can do.
to provide a general-purpose LOD
capability because (1) they have
a limit to the number of new
vertices that they can create, and