thebookofshaders/glossary/sign.md

21 lines
488 B
Markdown
Raw Normal View History

2015-04-17 04:52:51 +00:00
## Sign
Extract the sign of the parameter
2015-04-18 14:41:34 +00:00
### Declaration
2015-04-17 04:52:51 +00:00
```glsl
float sign(float x)
vec2 sign(vec2 x)
vec3 sign(vec3 x)
vec4 sign(vec4 x)
```
### Parameters
2015-04-18 14:41:34 +00:00
```x``` specify the value from which to extract the sign.
2015-04-17 04:52:51 +00:00
### Description
```sign()``` returns -1.0 if x is less than 0.0, 0.0 if x is equal to 0.0, and +1.0 if x is greater than 0.0.
<div class="simpleFunction" data="y = sign(x); "></div>
### See Also
2015-04-17 18:16:45 +00:00
[abs](index.html#abs.md), [Chapter 05: Shaping Functions](../05/)