You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
4 Variables and Types<br />
There is not an inout storage qualifier at global scope for declaring a single variable name as both input<br />
and output to a shader. Output variables must be declared with different names than input variables.<br />
However, nesting an input or output inside an interface block with an instance name allows the same<br />
names with one referenced through a block instance name.<br />
Vertex, tessellation evaluation, and geometry output variables output per-vertex data and are declared<br />
using the out, centroid out, or sample out storage qualifiers, or the deprecated varying storage qualifier.<br />
It is an error to use patch out in a vertex, tessellation evaluation, or geometry shader. Output variables<br />
can only be floating-point scalars, floating-point vectors, matrices, signed or unsigned integers or integer<br />
vectors, or arrays or structures of any these.<br />
Individual vertex, tessellation evaluation, and geometry outputs are declared as in the following examples:<br />
out vec3 normal;<br />
centroid out vec2 TexCoord;<br />
invariant centroid out vec4 Color;<br />
noperspective out float temperature; // varying is deprecated<br />
flat out vec3 myColor;<br />
noperspective centroid out vec2 myTexCoord;<br />
sample out vec4 perSampleColor;<br />
These can also appear in interface blocks, as described in section 4.3.7 “Interface Blocks”. Interface<br />
blocks allow simpler addition of arrays to the interface from vertex to geometry shader. They also allow a<br />
fragment shader to have the same input interface as a geometry shader for a given vertex shader.<br />
Tessellation control shader output variables are may be used to output per-vertex and per-patch data. Pervertex<br />
output variables are arrayed (see arrayed under 4.3.4 Inputs) and declared using out or centroid<br />
out storage qualifiers. Per-patch output variables are declared using the patch out storage qualifier. Pervertex<br />
and per-patch output variables can only be floating-point scalars, floating-point vectors, matrices,<br />
signed or unsigned integers or integer vectors, or arrays or structures of any these. Since tessellation<br />
control shaders produce an arrayed primitive comprising multiple vertices, each per-vertex output variable<br />
(or output block, see interface blocks below) needs to be declared as an array. For example,<br />
out float foo[]; // feeds next stage input “in float foo[]”<br />
Each element of such an array corresponds to one vertex of the primitive being produced. Each array can<br />
optionally have a size declared. The array size will be set by (or if provided must be consistent with) the<br />
output layout declaration(s) establishing the number of vertices in the output patch, as described later in<br />
section 4.3.8.2 “Output Layout Qualifiers”.<br />
As described under the section 4.3.4 “Inputs” above, if a per-vertex output of the tessellation control<br />
shader is itself an array with multiple values per vertex, it must appear in an output block (see interface<br />
blocks below) in the tessellation control shader with a block instance name declared as an array.<br />
Each tessellation control shader invocation has a corresponding output patch vertex, and may assign<br />
values to per-vertex outputs only if they belong to that corresponding vertex. If a per-vertex output<br />
variable is used as an l-value, it is an error if the expression indicating the vertex index is not the identifier<br />
gl_InvocationID.<br />
37