Let's switch to a C++ demo I actually wrote one a couple years ago We took a function out of it, but I forgot I'd finished so much of it Did add a program that makes functions Geometry shaders! The most flexible type in the pipeline Consequently the easiest area to make a good hangup But, they also have great power to change things! The pipeline: https://www.khronos.org/opengl/wiki/Rendering_Pipeline_Overview Let's copy something with a geometry shader! What geometry shaders do: Input: Primitives, POST vertex shader! Output: Primitives, not to be vertex shaded! Remember the order here, since it makes a fair bit of difference Ok, copying the triangle: input, and layouts (lines) Comes as an array output, and layout again EmitVertex() sort of takes care of the array thing No GL_LINES here, but we can use line_strip and EndPrimitive() Copying over of colors: Can make a difference Suggested reference: https://www.khronos.org/opengl/wiki/Geometry_Shader Another suggestion: http://www.lighthouse3d.com/tutorials/glsl-tutorial/geometry-shader/ Exploiting Parallelism: Invocations We can make the duplicate using another invocation, with gl_InvocationID Only on OpenGL 4.0+ Can't run it in a loop, or recursively, or anything like that Can have a loop inside it if you want Feedback, which we haven't got to yet, can sort of give you this Can access uniform variables in the geometry shader So we could kinda just not use the vertex shader... But we have less invocations to work with And we have to have a vertex shader program anyway Certainly can, though! We could cull vertices above a certain point that way... Another use: Normal Vectors Since we've got all three points of a triangle, we can calculate a face normal Important for lighting Which direction should it go? Usually depends which order the points are specified Clockwise vs. counterclockwise OpenGL defaults to counter-clockwise, but you can change it Should we calculate some? It's just a cross product I'd like to do it Monday at the latest