How it works...

The vertex shader is a simple passthrough shader. It converts the vertex position and normal to camera coordinates and sends them along, via VPosition and VNormal. These will be used for shading within the fragment shader and will be passed along (or ignored) by the geometry shader. The position is also converted to clip coordinates (or normalized device coordinates) by transforming with the model-view projection matrix, and it is then assigned to the built-in gl_Position.

The geometry shader begins by defining the input and output primitive types using the layout directive:

layout( triangles_adjacency ) in; 
layout( triangle_strip, max_vertices = 15 ) out;

This indicates that the input primitive type is triangles with adjacency ...

Get OpenGL 4 Shading Language Cookbook - Third 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.