2022-01-16 05:17:35 +01:00
|
|
|
//
|
|
|
|
// Simple passthrough fragment shader
|
|
|
|
//
|
|
|
|
varying vec2 v_vTexcoord;
|
|
|
|
varying vec4 v_vColour;
|
|
|
|
|
|
|
|
uniform vec2 position;
|
2022-11-01 03:06:03 +01:00
|
|
|
uniform vec2 dimension;
|
2022-01-16 05:17:35 +01:00
|
|
|
uniform vec2 scale;
|
2022-01-19 14:48:30 +01:00
|
|
|
uniform float angle;
|
2022-01-16 05:17:35 +01:00
|
|
|
uniform float width;
|
2022-09-21 06:09:40 +02:00
|
|
|
uniform float shift;
|
|
|
|
uniform int shiftAxis;
|
|
|
|
|
|
|
|
uniform vec4 col1, col2;
|
|
|
|
uniform int useSampler;
|
2022-01-16 05:17:35 +01:00
|
|
|
|
|
|
|
void main() {
|
2022-01-19 14:48:30 +01:00
|
|
|
vec2 pos = v_vTexcoord - position, _pos;
|
2022-11-01 03:06:03 +01:00
|
|
|
float ratio = dimension.x / dimension.y;
|
|
|
|
_pos.x = pos.x * ratio * cos(angle) - pos.y * sin(angle);
|
|
|
|
_pos.y = pos.x * ratio * sin(angle) + pos.y * cos(angle);
|
2022-01-16 05:17:35 +01:00
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
if(shiftAxis == 0) {
|
|
|
|
float cellY = floor(_pos.y * scale.y);
|
|
|
|
float shiftX = mod(cellY, 2.) * shift;
|
|
|
|
|
|
|
|
_pos.x += shiftX;
|
|
|
|
} else {
|
|
|
|
float cellX = floor(_pos.x * scale.x);
|
|
|
|
float shiftY = mod(cellX, 2.) * shift;
|
|
|
|
|
|
|
|
_pos.y += shiftY;
|
|
|
|
}
|
|
|
|
|
2022-01-16 05:17:35 +01:00
|
|
|
vec2 dist = _pos - floor(_pos * scale) / scale;
|
|
|
|
float ww = width / 2.;
|
|
|
|
|
2022-09-21 06:09:40 +02:00
|
|
|
if(useSampler == 0) {
|
|
|
|
if(dist == clamp(dist, vec2(ww), vec2(1. / scale - ww)))
|
|
|
|
gl_FragColor = vec4(col1.rgb, 1.);
|
|
|
|
else
|
|
|
|
gl_FragColor = vec4(col2.rgb, 1.);
|
|
|
|
} else {
|
|
|
|
vec2 uv = fract(_pos * scale);
|
|
|
|
gl_FragColor = texture2D( gm_BaseTexture, uv );
|
|
|
|
}
|
2022-01-16 05:17:35 +01:00
|
|
|
}
|