Expand description
Built-in funcions defined in GLSL specification chapter 8.
Functions§
- abs
- Returns
xifx ≥ 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
trueonly if all components ofxare true. - any
- Returns
trueif any component ofxis 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
bitsleast-significant bits ofinsertintobase. - 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
clampthat 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
xandy. - degrees
- Converts
radiansto degrees, i.e.,180/π * radians. - determinant
- Returns the determinant of
m. - distance
- Returns the distance between
p0andp1, i.e.,length(p0 – p1). - dot
- Returns the dot product of
xandy, 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
2raised to the power ofx. i.e., 2x. - faceforward
- If
dot(Nref, I) < 0return 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
xinto 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
xandy, 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
trueifxholds a NaN. Returnsfalseotherwise. - ldexp
- Builds a floating-point number from
xand 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 valueywhich satisfies x = ey. - log2
- Returns the base
2logarithm ofx. i.e., the valueywhich satisfies x = 2y. - matrix
Comp Mult - Multiply matrix
xby matrixycomponent-wise, i.e.,result[i][j]is the scalar product ofx[i][j]andy[i][j]. - max
- Returns
yifx < y, otherwise it returnsx. - max_s
- A variant of
maxthat always uses a scalar value as the comparator. - min
- Returns
yify < x, otherwise it returnsx. - min_s
- A variant of function
minthat uses a scalar value as comparator. - mix
- Returns the linear blend of
xandy, i.e.,x⋅(1−a)+y⋅a. - mix_
bool - Selects which vector each returned component comes from.
- mix_s
- A variant of function
mixthat parameterais 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
xbut 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
cas a column vector (matrix with one column) and the second parameterras 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 incand whose number of columns is the number of components inr. - pack
Double2x32 ⚠ - Returns a double-precision value obtained by packing the components of
vinto a 64-bit value. - pack
Snorm2x16 ⚠ - First, converts each component of the normalized floating-point value
vinto 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
vinto 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
vinto 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
vinto 8-bit integer values. Then, the results are packed into the returned 32-bit unsigned integer. - pow
- Returns
xraised to theypower, i.e., xy. - radians
- Converts
degreesto 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.0ifx > 0,0.0ifx = 0, or–1.0ifx < 0. - sin
- The standard trigonometric sine function.
- sinh
- Returns the hyperbolic sine function (ex - e-x) / 2.
- smoothstep
- Returns
0.0ifx ≤ edge0and1.0ifx ≥ edge1and performs smooth Hermite interpolation between 0 and 1 whenedge0 < x < edge1. - smoothstep_
s - A variant of
smoothstepfunction that use scalar as edges. - sqrt
- Returns the square root of
x. i.e., the valuesqrt(x). - step
- Returns
0.0ifx<edge, otherwise it returns1.0. - step_s
- A variant of
stepfunction 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
xwhose absolute value is not larger than the absolute value ofx. - uadd
Carry - Adds 32-bit unsigned integer
xandy, 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
xandy, producing a 64-bit result. - unpack
Double2x32 ⚠ - Returns a two-component unsigned integer vector representation of
v. The bit-level representation ofvis preserved. - unpack
Snorm2x16 ⚠ - First, unpacks a single 32-bit unsigned integer
pinto 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
pinto 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
pinto 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
pinto 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
yfromx, returning the difference and the borrow bit.