Graphics Reference
In-Depth Information
Applications should be encouraged to use the built-in functions rather
than do the equivalent computations in their own shader code because
the built-in functions are assumed to be optimal (e.g., perhaps supported
directly in hardware).
When the built-in functions are specified below, where the input
arguments (and corresponding output) can be
float,
,
vec2
,
vec3
, or
vec4
,
genType
is used as the argument. Where the input arguments (and
corresponding output) can be
int
,
ivec2
,
ivec3
, or
ivec4
,
genIType
is
used as the argument. Where the input arguments (and corresponding
output) can be
uint
,
uvec2
,
uvec3
, or
uvec4
,
genUType
is used as the
argument. Where the input arguments (or corresponding output) can be
bool
,
bvec2
,
bvec3
, or
bvec4
,
genBType
is used as the argument. For
any specific use of a function, the actual types substituted for
genType
,
genIType
,
genUType
, or
genBType
have to have the same number of
components for all arguments and for the return type. Similarly for
mat
,
which can be any matrix basic type.
The precision of built-in functions is dependent on the function and
arguments. There are three categories:
• Some functions have predefined precisions. The precision is specified;
for example,
highp ivec2
textureSize
(gsampler2D
sampler
, int
lod
)
• For the texture sampling functions, the precision of the return type
matches the precision of the sampler type:
uniform lowp sampler2D sampler;
highp vec2 coord;
. . .
// texture() returns lowp
lowp vec4 col = texture(sampler, coord);
• For other built-in functions, a call will return a precision qualification
matching the highest precision qualification of the call's input
arguments.
The built-in functions are assumed to be implemented according to the
equations specified in the following sections.