OpenGL ES 2.0 / GLSL 1.0
Qualifiers
最終更新:
opengles
-
view
Storage Qualifiers [4.3]
Variable declarations may be preceded by one storage qualifier.
none | (Default) local read/write memory, or input parameter |
const | Compile-time constant, or read-only function parameter |
attribute | Linkage between a vertex shader and OpenGL ES for per-vertex data |
uniform | Value does not change across the primitive being processed, uniforms form the linkage between a shader, OpenGL ES, and the application |
varying | Linkage between a vertex shader and fragment shader for interpolated data |
Uniform [4.3.4]
Use to declare global variables whose values are the same across the entire primitive being processed. All uniform variables are read-only. Use uniform qualifiers with any basic data types, to declare a variable whose type is a structure, or an array of any of these. For example:
- uniform vec4 lightPosition;
Varying [4.3.5]
The varying qualifier can be used only with the data types float, vec2, vec3, vec4, mat2, mat3, mat4, or arrays of these.
Structures cannot be varying. Varying variables are required to have global scope. Declaration is as follows:
Structures cannot be varying. Varying variables are required to have global scope. Declaration is as follows:
- varying vec3 normal;
Parameter Qualifiers [4.4]
Input values are copied in at function call time, output values are copied out at function return time.
none | (Default) same as in |
in | For function parameters passed into a function |
out | For function parameters passed back out of a function, but not initialized for use when passed in |
inout | For function parameters passed both into and out of a function |
Precision and Precision Qualifiers [4.5]
Any floating point, integer, or sampler declaration can have the type preceded by one of these precision qualifiers:
highp | Satisfies minimum requirements for the vertex language. Optional in the fragment language. |
mediump | Satisfies minimum requirements for the fragment language. Its range and precision is between that provided by lowp and highp. |
lowp | Range and precision can be less than mediump, but still represents all color values for any color channel. |
For example:
- lowp float color;
- varying mediump vec2 Coord;
- lowp ivec2 foo(lowp mat3);
- highp mat4 m;
Ranges & precisions for precision qualifiers (FP=floating point):
FP Range | FP Magnitude | Range FP Precision | Integer Range | |
highp | (−262 , 262) | (2–62 , 262) | Relative 2–16 | (−216 , 216) |
mediump | (−214 , 214) | (2–14, 214) | Relative 2–10 | (−210 , 210) |
lowp | (−2, 2) | (2–8, 2) | Absolute 2–8 | (−28 , 28) |
A precision statement establishes a default precision qualifier
for subsequent int, float, and sampler declarations, e.g.:
for subsequent int, float, and sampler declarations, e.g.:
- precision highp int;
Invariant Qualifiers Examples [4.6]
#pragma STDGL invariant(all) | Force all output variables to be invariant |
invariant gl_Position; | Qualify a previously declared variable |
invariant varying mediump vec3 Color; | Qualify as part of a variable declaration |
Order of Qualification [4.7]
When multiple qualifications are present, they must follow a
strict order. This order is as follows.
strict order. This order is as follows.
invariant, storage, precision
storage, parameter, precision