Math Shaders
- abs
- Returns the absolute value. For vectors, the absolute value is calculated on each component of the input, and the answer is returned as a vector of values.
- acos
- Returns the arc cosine in radians. For vectors, the arc cosine is calculated on each component of the input, and the answer is returned as a vector of values.
- add
- Returns the sum of the two inputs. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- all
- Returns true if all components of the input are true or not equal to zero, and returns false otherwise.
- and
- Returns true if both the first input and the second are true. Otherwise, returns false. For boolean vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- any
- Returns true if one or more components of the input is true or not equal to zero, and returns false otherwise.
- asin
- Returns the arc sine in radians. For vectors, the arc sine is calculated on each component of the input, and the answer is returned as a vector of values.
- atan
- Returns the arc tangent in radians. For vectors, the arc tangent is calculated on each component of the input, and the answer is returned as a vector of values.
- atan2
- Returns the arc tangent, in radians, of the first input divided by the second input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- Boolean_in_raster_position_range
- Returns true when the current shading point is within bounds of the specified minimum and maximum raster positions. Otherwise, returns false.
- ceil
- Returns the smallest integer greater than the input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- clamp
- Compares a given number to a minimum value and a maximum value. If the given number is less than the minimum, then the minimum value is returned. If the given number is greater than the maximum, then the maximum value is returned. Otherwise, the given value itself is returned. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values. The minimum and maximum values given may be vectors used component by component, or as scalars or integers to be used uniformly across all components.
- compress
- Scales numbers in the domain [0, 1] to fit a given range [Low, High]. Returns the placement of a given input in the given range by using the formula input * (High - Low) + Low. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- conditional
- Returns the first input if the boolean conditional flag is set to true, and returns the second input if the boolean conditional flag is set to false.
- cos
- Returns the cosine, where the input is interpreted in radians. For vectors, the cosine is calculated on each component of the input, and the answer is returned as a vector of values.
- cross
- Returns the cross product of the two input vectors. This function can only operate on scalar vectors of length 3.
- ddx
- Returns an approximation of the partial derivative of the input with respect to the x-coordinate in screen space. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values. For hardware, this function may not be used inside a conditional statement. For software, the value of the input must be one of the following state values: origin, position, direction, normal, geometry_normal, motion, parametric_uv, texture_coordinate[256], texture_tangent[256], or texture_binormal[256].
- ddy
- Returns an approximation of the partial derivative of the input with respect to the y-coordinate in screen space. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values. For hardware, this function may not be used inside a conditional statement. For software, the value of the input must be one of the following state values: origin, position, direction, normal, geometry_normal, motion, parametric_uv, texture_coordinate[256], texture_tangent[256], or texture_binormal[256].
- degrees
- Converts each component of the input from radians to degrees.
- distance
- Returns the distance between the two inputs.
- divide
- Returns the quotient of the two inputs. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- dot
- Returns the dot product of the two inputs.
- equal
- Returns true if the two inputs are identical to each other. Otherwise, returns false.
- exp
- Applies the exponential function to the input. For vectors, e is raised to the power of each component of the input, and the answer is returned as a vector.
- exp2
- Raises 2 to the power of the input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- expand
- Scales numbers in a given domain [Low, High] to fit the range [0, 1]. Returns the placement of a given input in the [0, 1] range by using the formula (input - Low) / (High - Low). For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- faceforward
- Returns a given vector or its negative, depending whether the dot product of two other given vectors is negative or positive, respectively.
- floor
- Returns the largest integer less than the input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- fmod
- Returns the remainder of dividing the first input by the second. For vectors, the modulo is calculated on each component of the input and the answer is returned as a vector.
- frac
- Returns the positive fractional part of the input, i.e. the scalar difference between the input and the largest integer less than the input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- greater_than
- Returns true if the first input is greater than the second input. Otherwise, returns false. For vectors, this calculation is made on each component of the input, and the answer is returned as a boolean vector.
- greater_than_or_equal
- Returns true if the first input is greater than or equal to the second input. Otherwise, returns false. For vectors, this calculation is made on each component of the input, and the answer is returned as a boolean vector.
- invert
- Returns the difference between 1 and the input, i.e. 1 - input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- length
- Returns the length of the input.
- lerp
- Performs linear interpolation between two input values a and b based on an input value x. Returns a * (1 - x) + b * x. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- less_than
- Returns true if the first input is less than the second input. Otherwise, returns false. For vectors, this calculation is made on each component of the input, and the answer is returned as a boolean vector.
- less_than_or_equal
- Returns true if the first input is less than or equal to the second input. Otherwise, returns false. For vectors, this calculation is made on each component of the input, and the answer is returned as a boolean vector.
- log
- Computes the natural logarithm, i.e. the base e logarithm, of the input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- log2
- Computes the base 2 logarithm of the input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- log10
- Computes the base 10 logarithm of the input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- max
- Compares two input values and returns the greater of the two. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- min
- Compares two input values and returns the lesser of the two. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- mix
- Performs linear interpolation between two input values a and b based on an input value x. Returns a * (1 - x) + b * x. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- modf
- Splits the input into its integral and fractional parts, each of which is given the same sign as the input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- multiply
- Returns the product of the two inputs. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- normalize
- Returns a vector of length 1 that points in the same direction as the given vector, i.e. scales the input vector so that it has length 1.
- not_equal
- Returns true if the two inputs are not identical to each other. Otherwise, returns false.
- or
- Returns true if at least one of the two inputs is true. Otherwise, returns false. For boolean vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- pow
- Returns the first input raised to the power of the second input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector.
- radians
- Converts each component of the input from degrees to radians.
- reflect
- Returns the reflection of a given vector about a given normal vector. The given vector is assumed to be pointing towards the surface represented by the normal. This function can only operate on scalar vectors of length 3.
- refract
- Returns the refraction of a given ray direction that is incoming to a surface with the given normal at a given index of refraction. If the angle between the incoming ray and the normal is too large for the given index of refraction, the zero vector is returned. This function can only operate on scalar vectors of length 3.
- round
- Rounds the input to the nearest integer. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- rsqrt
- Calculates the square root of the input and returns its reciprocal, i.e. returns 1 divided by the square root of the input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- saturate
- Compares a given number to 0 and 1. If the given number is less than 0, then 0 is returned. If the given number is greater than 1, then 1 is returned. Otherwise, the given value itself is returned. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- sign
- Returns 1 if the input is greater than zero, 0 if the input is zero, and -1 if the input is less than zero. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- sin
- Returns the sine, where the input is interpreted in radians. For vectors, the sine is calculated on each component of the input, and the answer is returned as a vector of values.
- sincos
- Calculates the sine of the input and the cosine of the input, where the input is interpreted in radians. For vectors, the sine and cosine are calculated on each component of the input, and the answers are returned vectors of values.
- smoothstep
- Returns 0 if a given number is less than a given number a and 1 if the given number is greater than b. A smooth curve is applied in the interval [a, b] so that the returned value if the given number lies in this interval vary continuously from 0 to 1. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- sqrt
- Returns the square root of the input. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- step
- Returns 0 if a given number is less than a given number a, and returns 1 otherwise. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- subtract
- Returns the difference of the two inputs. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.
- tan
- Returns the tangent, where the input is interpreted in radians. For vectors, the tangent is calculated on each component of the input, and the answer is returned as a vector of values.
- tex1d
- Returns the value of a given one-dimensional texture at a given coordinate. This function can only operate on colors.
- tex2d
- Returns the value of a given two-dimensional texture at a given coordinate. This function can only operate on colors.
- tex3d
- Returns the value of a given three-dimensional texture at a given coordinate. This function can only operate on colors.
- texcube
- Returns the value of a given cube texture at a given coordinate. This function can only operate on colors.
- threshold
- Returns 0 if the input is less than or equal to a given threshold. Otherwise, returns the input itself. For vectors, this calculation is made on each component of the input, and the answer is returned as a vector of values.