﻿ Section 5.2.  Exponential Functions

Free JavaScript Editor     Ajax Editor ﻿

Main Page

### 5.2. Exponential Functions

Exponential functions can be used within either vertex shaders or fragment shaders. These all operate component-wise (see Table 5.2). The description column specifies the operation on each component.

##### Table 5.2. Exponential functions

Syntax

Description

float pow (float x, float y)
vec2 pow (vec2 x, vec2 y)
vec3 pow (vec3 x, vec3 y)
vec4 pow (vec4 x, vec4 y)

Returns x raised to the y power, i.e., xy. Results are undefined if x < 0. Results are undefined if x = 0 and y = 0.

float exp (float x)
vec2 exp (vec2 x)
vec3 exp (vec3 x)
vec4 exp (vec4 x)

Returns the natural exponentiation of x, i.e., ex.

float log (float x)
vec2 log (vec2 x)
vec3 log (vec3 x)
vec4 log (vec4 x)

Returns the natural logarithm of x, i.e., returns the value y, which satisfies the equation x = ey.
Results are undefined if x <= 0.

float exp2 (float x)
vec2 exp2 (vec2 x)
vec3 exp2 (vec3 x)
vec4 exp2 (vec4 x)

Returns 2 raised to the x power, i.e., 2x.

float log2 (float x)
vec2 log2 (vec2 x)
vec3 log2 (vec3 x)
vec4 log2 (vec4 x)

Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2y. Results are undefined if x <= 0.

float sqrt (float x)
vec2 sqrt (vec2 x)
vec3 sqrt (vec3 x)
vec4 sqrt (vec4 x)

Returns the positive square root of x. Results are undefined if x < 0.

float inversesqrt (float x)
vec2 inversesqrt (vec2 x)
vec3 inversesqrt (vec3 x)
vec4 inversesqrt (vec4 x)

Returns the reciprocal of the positive square root of x. Results are undefined if x <= 0.

﻿

Ajax Editor     JavaScript Editor