How fractional_even_spacing Stops Tessellation Popping
In modern computer graphics, dynamic Level of Detail (LOD) algorithms
frequently alter surface mesh density based on the camera's proximity,
which can introduce a distracting visual artifact known as geometric
"popping." In OpenGL Shading Language (GLSL), the
fractional_even_spacing layout qualifier resolves this
issue within the tessellation primitive generator. By allowing
continuous floating-point subdivision levels instead of snapping to
discrete integers, it smoothly blends newly generated vertices into
existence, providing seamless transitions as geometry subdivides or
simplifies.
The Cause of Geometric Popping
When using standard equal_spacing, the tessellation
factor is rounded up to the nearest integer. As an object approaches the
camera, its calculated tessellation level increases continuously (e.g.,
from 3.9 to 4.0). Under integer-based spacing, crossing this threshold
forces the tessellator to instantaneously inject an entire set of new
vertices and edges across the patch.
When displacement mapping or non-linear vertex transformations are applied in the Tessellation Evaluation Shader (TES), these abruptly added vertices cause existing surfaces to suddenly snap to new positions. This visual discontinuity is what developers refer to as geometric popping.
How fractional_even_spacing Works
The fractional_even_spacing qualifier alters how the
hardware tessellator interprets the outer and inner tessellation levels
(gl_TessLevelOuter and gl_TessLevelInner).
Instead of truncating or rounding to an integer directly:
- Even Integer Ceiling: The floating-point tessellation level \(n\) is clamped to the operational range and then rounded up to the nearest even integer, \(2k\).
- Two Vanishing Segments: The domain edge is divided into \(2k\) segments. Of these segments, \(2k - 2\) segments have equal, full lengths, while two segments share a scaled, fractional length determined by the remainder of \(n\).
- Smooth Expansion: As \(n\) increases continuously toward \(2k\), these two transitional segments smoothly expand from a length of zero to their full size. Simultaneously, the other segments slightly contract to preserve domain proportions.
- Symmetrical Distribution: Because the system enforces an even number of divisions, the emerging segments are mirrored symmetrically across the center of the patch edge, preventing lopsided geometry or uneven vertex distribution.
Eliminating the Pop
Because the two emerging vertices begin at identical coordinates to existing patch points (zero length), their initial contribution to the shape of the surface is mathematically null. As the tessellation factor climbs, these vertices move away from their starting positions progressively rather than appearing out of nowhere.
When displacement shaders sample heightmaps or normal vectors at these new vertices, the transition occurs continuously across multiple frames. The user perceives a smooth deformation of the surface rather than a sudden structural jump, yielding stable and artifact-free dynamic terrain, water, and character meshes.