23.1. Flatshading

Flatshading 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

VK_PRIMITIVE_TOPOLOGY_POINT_LIST

$i$

VK_PRIMITIVE_TOPOLOGY_LINE_LIST

$2 i$

VK_PRIMITIVE_TOPOLOGY_LINE_STRIP

$i$

VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST

$3 i$

VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP

$i$

VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN

$i + 1$

VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY

$4 i + 1$

VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY

$i + 1$

VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY

$6 i$

VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY

$2 i$


[Note]editing-note

TODO: Add full caption:

Provoking vertex selection. The output values used for flatshading the ith primitive generated by drawing commands with the indicated primitive type are derived from the corresponding values of the vertex whose index is shown in the table. Primitives and vertices are numbered starting from zero.

Flatshading 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.