thebookofshaders/glossary/step.md

31 lines
915 B
Markdown
Raw Normal View History

2015-04-17 18:16:45 +00:00
## Step
Generate a step function by comparing two values
2015-04-18 14:41:34 +00:00
### Declaration
2015-04-17 18:16:45 +00:00
```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)
vec2 step(float edge, vec2 x)
vec3 step(float edge, vec3 x)
vec4 step(float edge, vec4 x)
```
### Parameters
2015-04-18 14:41:34 +00:00
```edge``` specifies the location of the edge of the step function.
2015-04-17 18:16:45 +00:00
2015-04-18 14:41:34 +00:00
```x``` specify the value to be used to generate the step function.
2015-04-17 18:16:45 +00:00
### 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/)