Graphics Reference
In-Depth Information
If a vertex or
tessellation shader
writes variables as
Then the geometry shader
will read them as
And will write the
new variables as
gl_Position
gl_PositionIn[•]
gl_Position
gl_PointSize
gl_PointSizeIn[•]
gl_PointSize
gl_Layer
gl_LayerIn[•]
gl_Layer
gl_PrimitiveID
gl_PrimitiveIDIn[•]
gl_PrimitiveID
In the geometry shader, the dimensions indicated by [•] are given by the
variable gl_VerticesIn , although you will already know this by the type of
geometry you are inputing. The dimensions are shown in the following table.
Input Topology Type
# Vertices in Arrays
GL_POINTS
1
GL_LINES
2
GL_LINES_ADJACENCY
4
GL_TRIANGLES
3
GL_TRIANGLES_ADJACENCY
6
The geometry shader can assign values to any of the GLSL variables in the right-
hand column to define the properties of the vertices it emits. When the geometry shader
calls EmitVertex( ) , this set of variables is copied to a slot in the shader's prim-
itive assembly step. So when the geometry shader calls EndPrimitive( ) , or
when the geometry shader ends (which implies that the primitive has ended),
the vertices that have been saved in the primitive assembly step are assembled,
rasterized, and further processed in the remainder of the standard graphics
pipeline.
You may wonder why, if there is an EndPrimitive( ) function, we have
not mentioned a BeginPrimitive( ) function. In fact, there is no such func-
tion; a primitive is deemed to begin at the start of the geometry shader or
at the return from any EndPrimitive( ) call. There is also no need to call
EndPrimitive( ) at the end of the geometry shader; this is implicit in the
shader's end, and ending any active primitive is part of the shader finishing
process. If it feels wrong to you to have no BeginPrimitive( ) function, it's
simple enough to create an empty function by
#define BeginPrimitive( ) ;
Search WWH ::




Custom Search