Pixel-Composer/shaders/sh_checkerboard/sh_checkerboard.fsh

26 lines
588 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;
2022-09-21 06:09:40 +02:00
uniform vec2 dimension;
uniform vec2 position;
2022-01-13 05:24:03 +01:00
uniform float angle;
uniform float amount;
2022-09-21 06:09:40 +02:00
uniform vec4 col1, col2;
2022-01-13 05:24:03 +01:00
void main() {
2022-09-21 06:09:40 +02:00
vec2 dimension_norm = dimension / dimension.y;
vec2 c = (v_vTexcoord - position) * dimension_norm;
float _x = c.x * cos(angle) - c.y * sin(angle);
float _y = c.x * sin(angle) + c.y * cos(angle);
2022-01-13 05:24:03 +01:00
float _a = 1. / amount;
if(mod(floor(_x / _a) + floor(_y / _a), 2.) > 0.5)
2022-09-21 06:09:40 +02:00
gl_FragColor = vec4(col1.rgb, 1.);
2022-01-13 05:24:03 +01:00
else
2022-09-21 06:09:40 +02:00
gl_FragColor = vec4(col2.rgb, 1.);
2022-01-13 05:24:03 +01:00
}