Lua Shader Common Functions

From GiderosMobile
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Function Syntax Description
abs abs(x) Returns the absolute of x.
sign sign(x) Returns the sign of x (-1, 0 or 1).
floor floor(x) Returns a value equal to the nearest integer that is less than or equal to x.
trunc trunc(x) Returns a value equal to the nearest integer to x whose absolute value is not larger than the absolute value of x.
round round(x) Returns a value equal to the nearest integer to x.
eround round(x) Returns a value equal to the nearest even integer to x.
ceil round(x) Returns a value equal to the nearest integer that is greater than or equal to x.
fract round(x) Returns 1/floor(x).
mod mod(x,y) Modulus, returns x-y*floor(x/y).
modf modf(x,y) Returns the fractional part of x and sets i to the integer part (as a whole number floating point value).
min mod(x,y) Returns the lower of x or y.
max mod(x,y) Returns the greater of x or y.
clamp clamp(x,minV,maxV) Returns min(max(x,minV),maxV).
mix mix(x,y,a) Returns the linear blend of x and y. i.e x*(1−a)+y*a
step step(edge,x) Returns 0.0 if x<edge, otherwise it returns 1.0.
smoothstep smoothstep(edge0,edge1,x) Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0<x<edge1.
isnan mix(x) Returns true if x holds a NaN (not a number).
isinf mix(x) Returns true if x holds a positive infinity or negative infinity.