thebookofshaders/glossary/sign
2020-07-30 16:34:42 +07:00
..
README-vi.md Translate the glossary section 2020-07-30 16:34:42 +07:00
README.md Remove trailing whitespaces 2017-08-23 11:34:44 +02:00

Sign

Extract the sign of the parameter

Declaration

float sign(float x)  
vec2 sign(vec2 x)  
vec3 sign(vec3 x)  
vec4 sign(vec4 x)

Parameters

x specify the value from which to extract the sign.

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.

See Also

abs, Chapter 05: Shaping Functions