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 />
evaluation shaders. As with other input variables, per-patch inputs must be declared using the same type<br />
and qualification as per-patch outputs from the previous (tessellation control) shader stage.<br />
Fragment shader inputs get per-fragment values, typically interpolated from a previous stage's outputs.<br />
They are declared in fragment shaders with the in storage qualifier. The auxiliary storage qualifiers<br />
centroid and sample can also be applied, as well as the interpolation qualifiers flat, noperspective, and<br />
smooth. It is an error to use patch in a fragment shader. Fragment inputs can only be signed and<br />
unsigned integers and integer vectors, floating point scalars, floating-point vectors, matrices, or arrays or<br />
structures of these. Fragment shader inputs that are signed or unsigned integers, integer vectors, or any<br />
double-precision floating-point type must be qualified with the interpolation qualifier flat.<br />
Fragment inputs are declared as in the following examples:<br />
in vec3 normal;<br />
centroid in vec2 TexCoord;<br />
invariant centroid in vec4 Color;<br />
noperspective in float temperature;<br />
flat in vec3 myColor;<br />
noperspective centroid in vec2 myTexCoord;<br />
The fragment shader inputs form an interface with the last active shader in the vertex processing pipeline.<br />
For this interface, the last active shader stage output variables and fragment shader input variables of the<br />
same name must match in type and qualification (other than out matching to in).<br />
When an interface between shader stages is formed using shaders from two separate program objects, it is<br />
not possible to detect mismatches between inputs and outputs when the programs are linked. When there<br />
are mismatches between inputs and outputs on such interfaces, the values passed across the interface will<br />
be partially or completely undefined. Shaders can ensure matches across such interfaces either by using<br />
input and output layout qualifiers (sections 4.4.1 “Input Layout Qualifiers” and 4.4.2 “Output Layout<br />
Qualifiers”) or by using identical input and output declarations of blocks or variables. Complete rules for<br />
interface matching between programs are found in the "Shader Interface Matching" portion of section<br />
2.14.PPO of the OpenGL Graphics System <strong>Spec</strong>ification.<br />
4.3.5 Uniform<br />
The uniform qualifier is used to declare global variables whose values are the same across the entire<br />
primitive being processed. All uniform variables are read-only and are initialized externally either at link<br />
time or through the API. The link time initial value is either the value of the variable's initializer, if<br />
present, or 0 if no initializer is present. Opaque types cannot have initializers.<br />
Example declarations are:<br />
uniform vec4 lightPosition;<br />
uniform vec3 color = vec3(0.7, 0.7, 0.2); // value assigned at link time<br />
The uniform qualifier can be used with any of the basic data types, or when declaring a variable whose<br />
type is a structure, or an array of any of these.<br />
There is an implementation dependent limit on the amount of storage for uniforms that can be used for<br />
each type of shader and if this is exceeded it will cause a compile-time or link-time error. Uniform<br />
variables that are declared but not used do not count against this limit. The number of user-defined<br />
40