Graphics Reference
In-Depth Information
Geometry shaders can access uniform variables, just like vertex and frag-
ment shaders can. They can also access all of the standard OpenGL-defined
variables, such as the transformation matrices. Thus, you can transform the
original vertices in the vertex shader, or transform them as they are being emit-
ted from the geometry shader, whichever is more convenient.
New Adjacency Primitives
As we saw in the brief discussion above, the geometry shader language intro-
duces some new geometric primitives to support the expansion capabilities in
this shader. These primitives add adjacency information to the fundamental
primitive, so that the additional adjacent vertices can be used in the primitive
expansion. At the OpenGL API level, these are reflected in additional argu-
ments to the familiar glBegin( ) function:
GL_LINES_ADJACENCY
GL_LINE_STRIP_ADJACENCY
GL_TRIANGLES_ADJACENCY
GL_TRIANGLE_STRIP_ADJACENCY
These arguments reflect the new adjacency primitives that are defined
with geometry shaders. The additional primitives, and the number and mean-
ing of the vertices that are used in implementing them if no geometry shader
is used, are listed below. If you use a geometry shader, you will define what
the vertices mean by the action of your shader.
Lines with adjacency . 4 N vertices are given (where N is the number of line
segments to draw). For each set of four vertices, a line segment is drawn
between vertex 1 and vertex 2. Vertices 0 and 3 are not part of the draw-
ing, but provide adjacency information.
Line strip with adjacency . N +3 vertices are given (where N is the number of
line segments to draw). A line segment is drawn between vertices 1 and
2, vertices 2 and 3, ..., and vertices N and N +1. Vertices 0 and N +2 are not
part of the drawing, but provide adjacency information.
Triangles with adjacency . 6 N vertices are given (where N is the number of
triangles to draw). For each triangle, vertices 0, 2, and 4 define the tri-
angle, while vertices 1, 3, and 5 tell where adjacent triangles are.
Triangle strip with adjacency . 4+2 N vertices are given (where N is the num-
ber of triangles to draw). Vertices 0, 2, 4, 6, 8, 10, ... define the triangles,
while vertices 1, 3, 5, 7, 9, 11, ... tell where adjacent triangles are.
These primitives are described graphically in Figure 12.3. This shows the
sets of input vertices and the way those vertices define the primitives for lines,
Search WWH ::




Custom Search