Graphics Reference
In-Depth Information
GLSL supports a familiar set of common
functions, as well as some that are not as familiar.
Among the less-familiar functions are some that are
very useful in combining colors or geometry. These
functions can all operate componentwise on any
vector. Note that the mod function is generalized to
real numbers as well as integers. The functions abs , clamp , min , max , and sign
can be applied to integers as well as to real numbers.
Don't use inversesqrt( )
to normalize a vector! Use
normalize( ) instead.
genType abs(genType x)
Returns x if x ≥ 0, otherwise returns - x .
genType sign(genType x)
Returns 1.0 if x > 0, 0.0 if x = 0, or -1.0 if x < 0.
genType floor(genType x)
Returns a value equal to the nearest integer that is less than
or equal to x .
genType ceil(genType x)
Returns a value equal to the nearest integer that is greater
than or equal to x .
genType fract(genType x)
Returns the fraction part of x : x - loor ( x ).
genType truncate (genType x)
Returns the integer closest to x whose absolute value is not
larger than abs ( x ).
Returns the integer closest to x .
genType round(genType x)
Generalized modulus. Returns x - y * loor ( x/y ).
genType mod(genType x, float y)
genType mod(genType x, genType y)
genType min(genType x, genType y)
genType min(genType x, float y)
Minimum. Returns y if y < x , otherwise returns x .
Maximum. Returns y if x < y , otherwise returns x .
genType max(genType x, genType y)
genType max(genType x, float y)
Clamped value; Returns min ( max ( x , minVal ), maxVal ).
Undefined if minVal > maxVal .
genType clamp(genType x,
genType minVal,
genType maxVal)
genType clamp(genType x,
float minVal,
float maxVal)
Proportional mix. Returns a linear combination of x and y :
a * x + (1 - a ) * y.
genType mix(genType x,
genType y,
genType a)
genType mix(genType x,
genType y,
float a)
genType mix(genType x,
genType y,
bool b)
Select the value of either x or y , depending on the value of
b .
Search WWH ::




Custom Search