adding more functions

pull/14/head
Patricio Gonzalez Vivo 10 years ago
parent 28f372e311
commit 2c96f43dcf

@ -17,4 +17,4 @@ vec4 abs(vec4 x)
<div class="simpleFunction" data="y = abs(x); "></div>
### See Also
[sign](index.html#sign.md)
[sign](index.html#sign.md), [min](index.html#min.md), [max](index.html#max.md), [Chapter 05: Shaping Functions](../05/)

@ -17,4 +17,4 @@ vec4 acos(vec4 x)
<div class="simpleFunction" data="y = acos(x); "></div>
### See Also
[cos](index.html#cos.md), [sin](index.html#sin.md), [asin](index.html#asin.md), [tan](index.html#tan.md), [atan](index.html#atan.md)
[cos](index.html#cos.md), [sin](index.html#sin.md), [asin](index.html#asin.md), [tan](index.html#tan.md), [atan](index.html#atan.md), [Chapter 05: Shaping Functions](../05/)

@ -17,4 +17,4 @@ vec4 asin(vec4 x)
<div class="simpleFunction" data="y = asin(x); "></div>
### See Also
[cos](index.html#cos.md), [sin](index.html#sin.md), [acos](index.html#acos.md), [tan](index.html#tan.md), [atan](index.html#atan.md)
[cos](index.html#cos.md), [sin](index.html#sin.md), [acos](index.html#acos.md), [tan](index.html#tan.md), [atan](index.html#atan.md), [Chapter 05: Shaping Functions](../05/)

@ -28,4 +28,4 @@ vec4 atan(vec4 y_over_x)
For the second overload, ```atan()``` returns the angle whose tangent is ```y_over_x```. Values returned in this case are in the range -PI to PI.
### See Also
[cos](index.html#cos.md), [acos](index.html#acos.md), [sin](index.html#sin.md), [asin](index.html#asin.md), [atan](index.html#atan.md)
[cos](index.html#cos.md), [acos](index.html#acos.md), [sin](index.html#sin.md), [asin](index.html#asin.md), [atan](index.html#atan.md), [Chapter 05: Shaping Functions](../05/), [Chapter 06: Color](../06/)

@ -0,0 +1,20 @@
## Ceil
Find the nearest integer that is greater than or equal to the parameter
```glsl
float ceil(float x)
vec2 ceil(vec2 x)
vec3 ceil(vec3 x)
vec4 ceil(vec4 x)
```
### Parameters
```x``` Specify the value to evaluate.
### Description
```ceil()``` returns a value equal to the nearest integer that is greater than or equal to ```x```.
<div class="simpleFunction" data="y = ceil(x); "></div>
### See Also
[floor](index.html#floor.md), [fract](index.html#fract.md), [mod](index.html#mod.md), [Chapter 05: Shaping Functions](../05/)

@ -0,0 +1,30 @@
## Clamp
Constrain a value to lie between two further values
```glsl
float clamp(float x, float minVal, float maxVal)
vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal)
vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal)
vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal)
```
```glsl
vec2 clamp(vec2 x, float minVal, float maxVal)
vec3 clamp(vec3 x, float minVal, float maxVal)
vec4 clamp(vec4 x, float minVal, float maxVal)
```
### Parameters
```x``` Specify the value to constrain.
```minVal``` Specify the lower end of the range into which to constrain x.
```maxVal``` Specify the upper end of the range into which to constrain x.
### Description
```clamp()``` returns the value of ```x``` constrained to the range ```minVal``` to ```maxVal```. The returned value is computed as ```min(max(x, minVal), maxVal)```.
<div class="simpleFunction" data="y = clamp(x,0.,1.); "></div>
### See Also
[min](index.html#min.md), [abs](index.html#abs.md), [max](index.html#max.md)

@ -17,4 +17,4 @@ vec4 cos(vec4 angle)
<div class="simpleFunction" data="y = cos(x); "></div>
### See Also
[acos](index.html#acos.md), [sin](index.html#sin.md), [asin](index.html#asin.md), [tan](index.html#tan.md), [atan](index.html#atan.md)
[acos](index.html#acos.md), [sin](index.html#sin.md), [asin](index.html#asin.md), [tan](index.html#tan.md), [atan](index.html#atan.md), [Chapter 05: Shaping Functions](../05/)

@ -18,4 +18,4 @@ vec4 exp(vec4 x)
### See Also
[log](index.html#log.md), [log2](index.html#log2.md), [exp2](index.html#exp2.md)
[log](index.html#log.md), [log2](index.html#log2.md), [exp2](index.html#exp2.md), [Chapter 05: Shaping Functions](../05/)

@ -18,4 +18,4 @@ vec4 exp2(vec4 x)
### See Also
[log](index.html#log.md), [log2](index.html#log2.md), [exp](index.html#exp.md)
[log](index.html#log.md), [log2](index.html#log2.md), [exp](index.html#exp.md), [Chapter 05: Shaping Functions](../05/)

@ -12,9 +12,9 @@ vec4 floor(vec4 x)
```x``` Specify the value to evaluate.
### Description
```sign()``` returns a value equal to the nearest integer that is less than or equal to x.
```floor()``` returns a value equal to the nearest integer that is less than or equal to ```x```.
<div class="simpleFunction" data="y = floor(x); "></div>
### See Also
[ceil](index.html#ceil.md), [trunc](index.html#trunc.md), [round](index.html#round.md)
[ceil](index.html#ceil.md), [fract](index.html#fract.md), [mod](index.html#mod.md), [Chapter 05: Shaping Functions](../05/)

@ -0,0 +1,20 @@
## Fract
Compute the fractional part of the argument
```glsl
float fract(float x)
vec2 fract(vec2 x)
vec3 fract(vec3 x)
vec4 fract(vec4 x)
```
### Parameters
```x``` Specify the value to evaluate.
### Description
```fract()``` returns the fractional part of ```x```. This is calculated as ```x - floor(x)```.
<div class="simpleFunction" data="y = fract(x); "></div>
### See Also
[floor](index.html#floor.md), [ceil](index.html#ceil.md), [mod](index.html#mod.md), [Chapter 05: Shaping Functions](../05/)

@ -18,4 +18,4 @@ vec4 inversesqrt(vec4 x)
### See Also
[pow](index.html#pow.md), [sqrt](index.html#sqrt.md)
[pow](index.html#pow.md), [sqrt](index.html#sqrt.md), [Chapter 05: Shaping Functions](../05/)

@ -18,4 +18,4 @@ vec4 log(vec4 x)
### See Also
[log2](index.html#log2.md), [exp](index.html#exp.md), [exp2](index.html#exp2.md)
[log2](index.html#log2.md), [exp](index.html#exp.md), [exp2](index.html#exp2.md), [Chapter 05: Shaping Functions](../05/)

@ -18,4 +18,4 @@ vec4 log2(vec4 x)
### See Also
[log](index.html#log.md), [exp](index.html#exp.md), [exp2](index.html#exp2.md)
[log](index.html#log.md), [exp](index.html#exp.md), [exp2](index.html#exp2.md), [Chapter 05: Shaping Functions](../05/)

@ -0,0 +1,28 @@
## Max
Return the greater of two values
```glsl
float max(float x, float y)
vec2 max(vec2 x, vec2 y)
vec3 max(vec3 x, vec3 y)
vec4 max(vec4 x, vec4 y)
```
```glsl
vec2 max(vec2 x, float y)
vec3 max(vec3 x, float y)
vec4 max(vec4 x, float y)
```
### Parameters
```x``` Specify the first value to compare.
```y``` Specify the second value to compare.
### Description
```max()``` returns the maximum of the two parameters. It returns ```y``` if ```y``` is greater than ```x```, otherwise it returns ```x```.
<div class="simpleFunction" data="y = max(x,0.5); "></div>
### See Also
[min](index.html#min.md), [abs](index.html#abs.md), [clamp](index.html#clamp.md), [Chapter 05: Shaping Functions](../05/)

@ -0,0 +1,28 @@
## Min
Return the lesser of two values
```glsl
float min(float x, float y)
vec2 min(vec2 x, vec2 y)
vec3 min(vec3 x, vec3 y)
vec4 min(vec4 x, vec4 y)
```
```glsl
vec2 min(vec2 x, float y)
vec3 min(vec3 x, float y)
vec4 min(vec4 x, float y)
```
### Parameters
```x``` Specify the first value to compare.
```y``` Specify the second value to compare.
### Description
```min()``` returns the minimum of the two parameters. It returns ```y``` if ```y``` is less than ```x```, otherwise it returns ```x```.
<div class="simpleFunction" data="y = min(x,0.5); "></div>
### See Also
[max](index.html#max.md), [abs](index.html#abs.md), [clamp](index.html#clamp.md), [Chapter 05: Shaping Functions](../05/)

@ -0,0 +1,33 @@
## Mix
Constrain a value to lie between two further values
```glsl
float mix(float x, float y, float a)
vec2 mix(vec2 x, vec2 y, vec2 a)
vec3 mix(vec3 x, vec3 y, vec3 a)
vec4 mix(vec4 x, vec4 y, vec4 a)
```
```glsl
vec2 mix(vec2 x, vec2 y, float a)
vec3 mix(vec3 x, vec3 y, float a)
vec4 mix(vec4 x, vec4 y, float a)
```
### Parameters
```x``` Specify the start of the range in which to interpolate.
```y``` Specify the end of the range in which to interpolate.
```a``` Specify the value to use to interpolate between x and y.
### Description
```mix()``` performs a linear interpolation between ```x``` and ```y``` using ```a``` to weight between them. The return value is computed as ```x×(1a)+y×a```.
<div class="codeAndCanvas" data="../06/mix.frag"></div>
<div class="codeAndCanvas" data="../06/gradient.frag"></div>
### See Also
[min](index.html#min.md), [max](index.html#max.md), [Chapter 06: Color](../06/)

@ -0,0 +1,27 @@
## Mod
Compute value of one parameter modulo another
```glsl
float mod(float x, float y)
vec2 mod(vec2 x, vec2 y)
vec3 mod(vec3 x, vec3 y)
vec4 mod(vec4 x, vec4 y)
```
```glsl
vec2 mod(vec2 x, float y)
vec3 mod(vec3 x, float y)
vec4 mod(vec4 x, float y)
```
### Parameters
```x``` Specify the value to evaluate.
```y``` Specify the value to obtain the modulo of.
### Description
```mod()``` returns the value of ```x``` modulo ```y```. This is computed as ```x - y * floor(x/y)```.
<div class="simpleFunction" data="y = mod(x,1.5); "></div>
### See Also
[floor](index.html#floor.md), [fract](index.html#fract.md), [ceil](index.html#ceil.md), [Chapter 05: Shaping Functions](../05/)

@ -20,4 +20,4 @@ vec4 pow(vec4 x, vec4 y)
### See Also
[inversesqrt](index.html#inversesqrt.md), [sqrt](index.html#sqrt.md)
[inversesqrt](index.html#inversesqrt.md), [sqrt](index.html#sqrt.md), [Chapter 05: Shaping Functions](../05/)

@ -17,4 +17,4 @@ vec4 sign(vec4 x)
<div class="simpleFunction" data="y = sign(x); "></div>
### See Also
[abs](index.html#abs.md)
[abs](index.html#abs.md), [Chapter 05: Shaping Functions](../05/)

@ -17,4 +17,4 @@ vec4 sin(vec4 angle)
<div class="simpleFunction" data="y = sin(x); "></div>
### See Also
[acos](index.html#acos.md), [cos](index.html#cos.md), [asin](index.html#asin.md), [tan](index.html#tan.md), [atan](index.html#atan.md)
[acos](index.html#acos.md), [cos](index.html#cos.md), [asin](index.html#asin.md), [tan](index.html#tan.md), [atan](index.html#atan.md), [Chapter 05: Shaping Functions](../05/)

@ -0,0 +1,39 @@
## Smoothstep
Perform Hermite interpolation between two values
```glsl
float smoothstep(float edge0, float edge1, float x)
vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x)
vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x)
vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x)
```
```glsl
vec2 smoothstep(float edge0, float edge1, vec2 x)
vec3 smoothstep(float edge0, float edge1, vec3 x)
vec4 smoothstep(float edge0, float edge1, vec4 x)
```
### Parameters
```edge0``` Specifies the value of the lower edge of the Hermite function.
```edge1``` Specifies the value of the upper edge of the Hermite function.
```x``` Specifies the source value for interpolation.
### Description
```smoothstep()``` performs smooth Hermite interpolation between ```0``` and ```1``` when ```edge0 < x < edge1```. This is useful in cases where a threshold function with a smooth transition is desired. ```smoothstep()``` is equivalent to:
```glsl
genType t; /* Or genDType t; */
t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
return t * t * (3.0 - 2.0 * t);
```
Results are undefined ```if edge0 ≥ edge1```.
<div class="simpleFunction" data="y = smoothstep(0.0,1.0,x); "></div>
<div class="codeAndCanvas" data="../05/smoothstep.frag"></div>
### See Also
[mix](index.html#mix.md), [step](index.html#step.md), [Chapter 05: Shaping Functions](../05/)

@ -17,4 +17,4 @@ vec4 sqrt(vec4 x)
<div class="simpleFunction" data="y = sqrt(x); "></div>
### See Also
[inversesqrt](index.html#inversesqrt.md), [pow](index.html#pow.md)
[inversesqrt](index.html#inversesqrt.md), [pow](index.html#pow.md), [Chapter 05: Shaping Functions](../05/)

@ -0,0 +1,32 @@
## Step
Generate a step function by comparing two values
```glsl
float step(float edge, float x)
vec2 step(vec2 edge, vec2 x)
vec3 step(vec3 edge, vec3 x)
vec4 step(vec4 edge, vec4 x)
```
```glsl
vec2 step(float edge, vec2 x)
vec3 step(float edge, vec3 x)
vec4 step(float edge, vec4 x)
```
### Parameters
```edge``` Specifies the location of the edge of the step function.
```x``` Specify the value to be used to generate the step function.
### Description
```step()``` generates a step function by comparing ```x``` to ```edge```.
For element ```i``` of the return value, ```0.0``` is returned ```if x[i] < edge[i]```, and ```1.0``` is returned otherwise.
<div class="simpleFunction" data="y = step(0.5,x); "></div>
<div class="codeAndCanvas" data="../05/step.frag"></div>
### See Also
[mix](index.html#mix.md), [smoothstep](index.html#smoothstep.md), [Chapter 05: Shaping Functions](../05/)

@ -17,4 +17,4 @@ vec4 tan(vec4 angle)
<div class="simpleFunction" data="y = tan(x); "></div>
### See Also
[cos](index.html#cos.md), [acos](index.html#acos.md), [sin](index.html#sin.md), [asin](index.html#asin.md), [atan](index.html#atan.md)
[cos](index.html#cos.md), [acos](index.html#acos.md), [sin](index.html#sin.md), [asin](index.html#asin.md), [atan](index.html#atan.md), [Chapter 05: Shaping Functions](../05/)
Loading…
Cancel
Save