Using a geometry shader
In the rendering pipeline, a geometry shader works between the vertex shader and the fragment shader. It processes the groups of vertices that are organized in primitives. The possible primitives are point (one vertex), line (two vertices), and triangle (three vertices). Also, there are two new primitives, line with adjacent and triangle with adjacent, which represent the line and the triangle with some additional vertices providing adjacency information needed for computing the normals.
The geometry shader gets access to the input positions of the primitive's vertices using a built-in array gl_PositionIn
, which holds values of type vec4
. These positions are equal to the output values gl_Position
generated by the vertex shader.
During its work, processing of the geometry shader should generate a number of output vertices by setting some values to gl_Position
, gl_FrontColor
, and other variables (similar to the vertex shader), and finally calling the EmitVertex()
function...