thebookofshaders/glossary/mod/README.md

27 lines
712 B
Markdown
Raw Normal View History

2015-04-17 18:16:45 +00:00
## Mod
Compute value of one parameter modulo another
2015-04-18 14:41:34 +00:00
### Declaration
2015-04-17 18:16:45 +00:00
```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)
vec2 mod(vec2 x, float y)
vec3 mod(vec3 x, float y)
vec4 mod(vec4 x, float y)
```
### Parameters
2015-04-18 14:41:34 +00:00
```x``` specify the value to evaluate.
```y``` specify the value to obtain the modulo of.
2015-04-17 18:16:45 +00:00
### 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
2017-08-19 10:11:58 +00:00
[floor](/glossary/?search=floor), [fract](/glossary/?search=fract), [ceil](/glossary/?search=ceil), [Chapter 05: Shaping Functions](/05/)