OpenGL Shader Functions
From GPWiki
| |
This article is a stub. You can help out by expanding it. |
There are many built in functions in GLSL. A complete listing, grouped by general function, follows.
Conventions for this page
For the sake of brevity, the following terms are used throughout this article.
- vec - A general name for a vec2, vec3, or vec4.
- mat - A general name for a mat2, mat3, or mat4.
- ivec - A general name for a ivec2, ivec3, or ivec4.
- bvec - A general name for a bvec2, bvec3, or bvec4.
- type - A general name for a float, vec2, vec3, or vec4.
Angle and Trigonometry Functions
- type sin(type) - Returns the sine of the angle. The angle must be given in radians.
- type cos(type) - Returns the cosine of the angle. The angle must be given in radians.
- type tan(type) - Returns the tangent of the angle. The angle must be given in radians.
- type asin(type) - Returns the arcsine of the input. The output is in radians
- type acos(type) - Returns the arccosine of the input. The output is in radians
- type atan(type) - Returns the arctangent of the input. The output is in radians
- type atan(type, type) - Returns the arctangent of the (y, x). The output is in radians.
- type radians(type) - Converts from degrees to radians.
- type degrees(type) - Converts from radians to degrees.
Exponential Functions
- type pow(type base, type power) - Raises the base to the specified power.
- type exp(type x) - Calculates e^x.
- type log(type) - Calculates the natural log of the input.
- type exp2(type x) - Calculates 2^x.
- type log2(type) - Calculates the log base 2 of the input.
- type sqrt(type) - Calculates the square root of the input.
- type inversesqrt(type) - Calculates the inverse square root of the input.