Flat shading a vertex output attribute means to assign all vertices of the primitive the same value for that output.
The output values assigned are those of the provoking vertex of the primitive. The provoking vertex depends on the primitive topology, and is generally the “first” vertex of the primitive. For primitives not processed by tessellation or geometry shaders, the provoking vertex is selected from the input vertices according to the following table.
Table 23.1. Provoking vertex selection
Primitive type of primitive i | Provoking vertex number |
| i |
| 2 i |
| i |
| 3 i |
| i |
| i + 1 |
| 4 i + 1 |
| i + 1 |
| 6 i |
| 2 i |
Flat shading is applied to those vertex attributes that
match fragment input attributes which
are decorated as Flat
.
If a geometry shader is active, the output primitive topology is either points, line strips, or triangle strips, and the selection of the provoking vertex behaves according to the corresponding row of the table. If a tessellation evaluation shader is active and a geometry shader is not active, the provoking vertex is undefined but must be one of the vertices of the primitive.