What is Clipping in OpenGL?

As you are learning OpenGL, you may come in contact with the term Clipping. Clipping is a stage in the graphics pipeline that determines which primitives to discard and which ones to pass through to the next stage.

The concept is not hard, so let me explain:

Did you notice how the output of the vertex shader, gl_Position, is of type vec4? vec4 in OpenGL means that the variable has four components: x, y, z and w. When a vector has four components it means it is in Homogeneous Space.

Clipping occurs after the Vertex Shader and Primitive Assembly stages. However, the output of these stages is in homogeneous space. To clip the primitives, they have to be in Cartesian Space. To convert from Homogeneous to Cartesian Space, OpenGL does a Projective Division. That is, it divides the four vector components by the last component w.

After the Projective Division, the vertices positions are now in Normalized Device Space. In OpenGL, the visible region of normalized space is the volume that extends from -1.0 to 1.0 in the x and y dimensions and from 0.0 to 1.0 in the z dimension. Any geometry that is within this volume, is visible to the viewer. Anything outside from this volume is discarded, Clipped, by OpenGL.

Simply put, Clipping discards primitives whose vertices are outside the Normalized Space viewing volume. Those that are within the normalized space pass through to the next stage in the pipeline.

Hope this helps clarify what Clipping is.

PS. Sign up to my newsletter and get OpenGL development tips.

Harold Serrano

Computer Graphics Enthusiast. Currently developing a 3D Game Engine.