Producing Primitives

Primitives are produced in the geometry shader with the two special built-in functions, EmitVertex() and EndPrimitive(). As already discussed, a single geometry shader invocation must call EmitVertex() and possibly EndPrimitive() to produce output primitives. If the geometry shader does not call these functions, no output geometry is produced, and the inputs to the shader are essentially discarded. This is culling. On the other hand, if the geometry shader calls EmitVertex() many times, it can produce more output than it receives at its input, amplifying the geometry.

Another unique feature of geometry shaders is that they can have a different primitive type for their output than they do for their input. This can be used ...

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.