Expand description
Built-in funcions defined in GLSL specification chapter 8.
Functions§
- abs
- Returns
x
ifx ≥ 0
, otherwise it returns–x
. - acos
- Returns an angle whose cosine is
x
. - acosh
- Arc hyperbolic cosine; returns the non-negative inverse of cosh.
- all
- Returns
true
only if all components ofx
are true. - any
- Returns
true
if any component ofx
is true. - asin
- Returns an angle whose sine is
x
. - asinh
- Arc hyperbolic sine; returns the inverse of sinh.
- atan
- Returns an angle whose tangent is
y_over_x
. - atan2
- Returns an angle whose tangent is
y / x
. - atanh
- Arc hyperbolic tangent; returns the inverse of tanh.
- bitCount
- Returns the number of bits set to 1 in the binary representation of
value
. - bitfield
Extract - Extracts bits
[offset, offset + bits - 1]
fromvalue
, returning them in the least significant bits of the result. - bitfield
Insert - Returns the insertion the
bits
least-significant bits ofinsert
intobase
. - bitfield
Reverse - Returns the reversal of the bits of
value
. - ceil
- Returns a value equal to the nearest integer that is greater than or
equal to
x
. - clamp
- Returns
min (max (x, min_val), max_val)
. - clamp_s
- A variant of function
clamp
that uses scalar values as thresholds. - cos
- The standard trigonometric cosine function.
- cosh
- Returns the hyperbolic cosine function (ex + e-x) / 2.
- cross
- Returns the cross product of
x
andy
. - degrees
- Converts
radians
to degrees, i.e.,180/π * radians
. - determinant
- Returns the determinant of
m
. - distance
- Returns the distance between
p0
andp1
, i.e.,length(p0 – p1)
. - dot
- Returns the dot product of
x
andy
, i.e.,x[0] * y[0] + x[1] * y[1] + ...
. - equal
- Returns the component-wise compare of
x == y
. - exp
- Returns the natural exponentiation of
x
. i.e., ex. - exp2
- Returns
2
raised to the power ofx
. i.e., 2x. - faceforward
- If
dot(Nref, I) < 0
return N, otherwise return -N. - findLSB
- Returns the bit number of the least significant bit set to 1 in the binary
representation of
value
. - findMSB
- Returns the bit number of the most significant bit in the binary
representation of
value
. - float
Bits ToInt - Returns a signed integer value representing the encoding of a floating-point value.
- float
Bits ToUint - Returns a unsigned integer value representing the encoding of a floating-point value.
- floor
- Returns a value equal to the nearest integer that is less than or
equal to
x
. - fma
- Computes and returns
a * b + c
. - fmod
- Modulus. Returns
x – y ∗ floor(x/y)
. - fract
- Returns
x – floor(x)
. - frexp
- Splits
x
into a floating-point significand in the range [0.5, 1.0) and an integral exponent of two, such that: x = significand⋅2exponent. - greater
Than - Returns the component-wise compare of
x > y
. - greater
Than Equal - Returns the component-wise compare of
x ≥ y
. - imul
Extended - Multiplies 32-bit integers
x
andy
, producing a 64-bit result. - intBits
ToFloat - Returns a floating-point value corresponding to a signed integer encoding of a floating-point value.
- inverse
- Returns a matrix that is the inverse of
m
. - inversesqrt
- Returns the inverse of the square root of
x
. i.e., the value1/sqrt(x)
. - isinf
- Returns true if x holds a positive infinity or negative infinity. Returns false otherwise.
- isnan
- Returns
true
ifx
holds a NaN. Returnsfalse
otherwise. - ldexp
- Builds a floating-point number from
x
and the corresponding integral exponent of two inexp
, returning: significand ⋅ 2exponent. - length
- Returns the length of vector
x
, i.e.,sqrt(x[0]^2 + x[1]^2 + ...)
. - less
Than - Returns the component-wise compare of
x < y
. - less
Than Equal - Returns the component-wise compare of
x ≤ y
. - log
- Returns the natural logarithm of
x
. i.e., the valuey
which satisfies x = ey. - log2
- Returns the base
2
logarithm ofx
. i.e., the valuey
which satisfies x = 2y. - matrix
Comp Mult - Multiply matrix
x
by matrixy
component-wise, i.e.,result[i][j]
is the scalar product ofx[i][j]
andy[i][j]
. - max
- Returns
y
ifx < y
, otherwise it returnsx
. - max_s
- A variant of
max
that always uses a scalar value as the comparator. - min
- Returns
y
ify < x
, otherwise it returnsx
. - min_s
- A variant of function
min
that uses a scalar value as comparator. - mix
- Returns the linear blend of
x
andy
, i.e.,x⋅(1−a)+y⋅a
. - mix_
bool - Selects which vector each returned component comes from.
- mix_s
- A variant of function
mix
that parametera
is a scalar. - mod_s
- Modulus with a scalar number.
- modf
- Returns the fractional and integer parts of
x
. - noise1
- Returns a 1D noise value based on the input value
x
. - noise2
- Returns a 2D noise value based on the input value
x
. - noise3
- Returns a 3D noise value based on the input value
x
. - noise4
- Returns a 4D noise value based on the input value
x
. - normalize
- Returns a vector in the same direction as
x
but with a length of1
. - not
- Returns the component-wise logical complement of
x
. - notEqual
- Returns the component-wise compare of
x ≠ y
. - outer
Product - Treats the first parameter
c
as a column vector (matrix with one column) and the second parameterr
as a row vector (matrix with one row) and does a linear algebraic matrix multiplyc * r
, yielding a matrix whose number of rows is the number of components inc
and whose number of columns is the number of components inr
. - pack
Double2x32 ⚠ - Returns a double-precision value obtained by packing the components of
v
into a 64-bit value. - pack
Snorm2x16 ⚠ - First, converts each component of the normalized floating-point value
v
into 16-bit integer values. Then, the results are packed into the returned 32-bit unsigned integer. - pack
Snorm4x8 ⚠ - First, converts each component of the normalized floating-point value
v
into 8-bit integer values. Then, the results are packed into the returned 32-bit unsigned integer. - pack
Unorm2x16 ⚠ - First, converts each component of the normalized floating-point value
v
into 16-bit integer values. Then, the results are packed into the returned 32-bit unsigned integer. - pack
Unorm4x8 ⚠ - First, converts each component of the normalized floating-point value
v
into 8-bit integer values. Then, the results are packed into the returned 32-bit unsigned integer. - pow
- Returns
x
raised to they
power, i.e., xy. - radians
- Converts
degrees
to radians, i.e.,π/180 * degrees
. - reflect
- For the incident vector I and surface orientation N,
returns the reflection direction:
I - 2 ∗ dot(N, I) ∗ N
. - refract
- For the incident vector I and surface normal N, and the ratio of
indices of refraction
eta
, return the refraction vector. - round
- Returns a value equal to the nearest integer to
x
. - round
Even - Returns a value equal to the nearest integer to
x
. - sign
- Returns
1.0
ifx > 0
,0.0
ifx = 0
, or–1.0
ifx < 0
. - sin
- The standard trigonometric sine function.
- sinh
- Returns the hyperbolic sine function (ex - e-x) / 2.
- smoothstep
- Returns
0.0
ifx ≤ edge0
and1.0
ifx ≥ edge1
and performs smooth Hermite interpolation between 0 and 1 whenedge0 < x < edge1
. - smoothstep_
s - A variant of
smoothstep
function that use scalar as edges. - sqrt
- Returns the square root of
x
. i.e., the valuesqrt(x)
. - step
- Returns
0.0
ifx
<edge
, otherwise it returns1.0
. - step_s
- A variant of
step
function that use scalar as the edge. - tan
- The standard trigonometric tangent.
- tanh
- Returns the hyperbolic tangent function
sinh(x)/cosh(x)
. - transpose
- Returns a matrix that is the transpose of
m
. - trunc
- Returns a value equal to the nearest integer to
x
whose absolute value is not larger than the absolute value ofx
. - uadd
Carry - Adds 32-bit unsigned integer
x
andy
, returning the sum modulus 232 and the carry bit. - uint
Bits ToFloat - Returns a floating-point value corresponding to a unsigned integer encoding of a floating-point value.
- umul
Extended - Multiplies 32-bit unsigned integers
x
andy
, producing a 64-bit result. - unpack
Double2x32 ⚠ - Returns a two-component unsigned integer vector representation of
v
. The bit-level representation ofv
is preserved. - unpack
Snorm2x16 ⚠ - First, unpacks a single 32-bit unsigned integer
p
into two 16-bit signed integers. Then, each component is converted to a normalized floating-point value to generate the returned two-component vector. - unpack
Snorm4x8 ⚠ - First, unpacks a single 32-bit unsigned integer
p
into four 8-bit signed integers. Then, each component is converted to a normalized floating-point value to generate the returned four-component vector. - unpack
Unorm2x16 ⚠ - First, unpacks a single 32-bit unsigned integer
p
into a pair of 16-bit unsigned integers. Then, each component is converted to a normalized floating-point value to generate the returned two-component vector. - unpack
Unorm4x8 ⚠ - First, unpacks a single 32-bit unsigned integer
p
into four 8-bit unsigned integers. Then, each component is converted to a normalized floating-point value to generate the returned four-component vector. - usub
Borrow - Subtracts the 32-bit unsigned integer
y
fromx
, returning the difference and the borrow bit.