2022-01-13 05:24:03 +01:00
|
|
|
//
|
|
|
|
// Simple passthrough fragment shader
|
|
|
|
//
|
|
|
|
varying vec2 v_vTexcoord;
|
|
|
|
varying vec4 v_vColour;
|
|
|
|
|
2022-01-17 08:52:51 +01:00
|
|
|
uniform vec2 position;
|
2022-09-21 06:09:40 +02:00
|
|
|
uniform int blend;
|
|
|
|
|
2023-12-23 12:59:21 +01:00
|
|
|
uniform vec2 amount;
|
|
|
|
uniform int amountUseSurf;
|
|
|
|
uniform sampler2D amountSurf;
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
uniform vec4 col1, col2;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
void main() {
|
2023-12-23 12:59:21 +01:00
|
|
|
float amo = amount.x;
|
|
|
|
if(amountUseSurf == 1) {
|
|
|
|
vec4 _vMap = texture2D( amountSurf, v_vTexcoord );
|
|
|
|
amo = mix(amount.x, amount.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
|
|
|
}
|
|
|
|
|
2022-01-17 08:52:51 +01:00
|
|
|
vec2 pos = v_vTexcoord - position;
|
2023-12-23 12:59:21 +01:00
|
|
|
float _cell = 1. / (amo * 2.);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-17 08:52:51 +01:00
|
|
|
float _xind = floor(pos.x / _cell);
|
|
|
|
float _yind = floor(pos.y / _cell);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-12-23 12:59:21 +01:00
|
|
|
float _xcell = fract(pos.x * amo * 2.);
|
|
|
|
float _ycell = fract(pos.y * amo * 2.);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
float _x = _xcell;
|
|
|
|
float _y = _ycell;
|
|
|
|
|
|
|
|
if(mod(_xind, 2.) == 1.)
|
2022-09-21 06:09:40 +02:00
|
|
|
_x = 1. - _xcell;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
if(blend == 0) {
|
|
|
|
if(mod(_yind, 2.) == 1.) {
|
2024-01-08 08:10:50 +01:00
|
|
|
if(_x > _y) gl_FragColor = col1;
|
|
|
|
else gl_FragColor = col2;
|
2022-09-21 06:09:40 +02:00
|
|
|
} else {
|
2024-01-08 08:10:50 +01:00
|
|
|
if(_x > _y) gl_FragColor = col2;
|
|
|
|
else gl_FragColor = col1;
|
2022-09-21 06:09:40 +02:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
} else {
|
2024-01-08 08:10:50 +01:00
|
|
|
if(_x > _y) gl_FragColor = mix(col1, col2, _y + (1. - _x));
|
|
|
|
else gl_FragColor = mix(col1, col2, _y - _x);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|