Pixel-Composer/shaders/sh_zigzag/sh_zigzag.fsh

38 lines
721 B
Plaintext
Raw Normal View History

2022-01-13 05:24:03 +01:00
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 position;
2022-01-13 05:24:03 +01:00
uniform float amount;
void main() {
vec2 pos = v_vTexcoord - position;
2022-01-13 05:24:03 +01:00
float _cell = 1. / (amount * 2.);
float _xind = floor(pos.x / _cell);
float _yind = floor(pos.y / _cell);
2022-01-13 05:24:03 +01:00
float _xcell = mod(pos.x, _cell);
float _ycell = mod(pos.y, _cell);
2022-01-13 05:24:03 +01:00
float _x = _xcell;
float _y = _ycell;
if(mod(_xind, 2.) == 1.)
_x = _cell - _xcell;
if(mod(_yind, 2.) == 1.) {
if(_x > _y)
gl_FragColor = vec4(vec3(0.), 1.);
else
gl_FragColor = vec4(vec3(1.), 1.);
} else {
if(_x > _y)
gl_FragColor = vec4(vec3(1.), 1.);
else
gl_FragColor = vec4(vec3(0.), 1.);
}
}