2019-01-23 01:34:11 +03:00
|
|
|
#version 140
|
|
|
|
|
2019-05-13 04:05:14 +03:00
|
|
|
// (x offset, y offset, zoom)
|
|
|
|
uniform vec3 transform;
|
|
|
|
// (window width, window height, hatching == 1.0)
|
|
|
|
uniform vec3 window;
|
|
|
|
|
2019-09-11 01:44:07 +03:00
|
|
|
uniform sampler2D tex0;
|
|
|
|
uniform sampler2D tex1;
|
|
|
|
uniform sampler2D tex2;
|
|
|
|
uniform sampler2D tex3;
|
|
|
|
uniform sampler2D tex4;
|
|
|
|
uniform sampler2D tex5;
|
|
|
|
uniform sampler2D tex6;
|
|
|
|
uniform sampler2D tex7;
|
|
|
|
uniform sampler2D tex8;
|
|
|
|
uniform sampler2D tex9;
|
2019-09-11 01:21:58 +03:00
|
|
|
|
2019-09-11 02:08:01 +03:00
|
|
|
in vec4 pass_style;
|
2019-01-23 01:34:11 +03:00
|
|
|
out vec4 f_color;
|
|
|
|
|
|
|
|
void main() {
|
2019-09-11 02:08:01 +03:00
|
|
|
if (pass_style[3] != 0.0) {
|
|
|
|
f_color = pass_style;
|
|
|
|
} else if (pass_style[0] == 0.0) {
|
|
|
|
f_color = texture(tex0, vec2(pass_style[1], pass_style[2]));
|
|
|
|
} else if (pass_style[0] == 1.0) {
|
|
|
|
f_color = texture(tex1, vec2(pass_style[1], pass_style[2]));
|
|
|
|
} else if (pass_style[0] == 2.0) {
|
|
|
|
f_color = texture(tex2, vec2(pass_style[1], pass_style[2]));
|
|
|
|
} else if (pass_style[0] == 3.0) {
|
|
|
|
f_color = texture(tex3, vec2(pass_style[1], pass_style[2]));
|
|
|
|
} else if (pass_style[0] == 4.0) {
|
|
|
|
f_color = texture(tex4, vec2(pass_style[1], pass_style[2]));
|
|
|
|
} else if (pass_style[0] == 5.0) {
|
|
|
|
f_color = texture(tex5, vec2(pass_style[1], pass_style[2]));
|
|
|
|
} else if (pass_style[0] == 6.0) {
|
|
|
|
f_color = texture(tex6, vec2(pass_style[1], pass_style[2]));
|
|
|
|
} else if (pass_style[0] == 7.0) {
|
|
|
|
f_color = texture(tex7, vec2(pass_style[1], pass_style[2]));
|
|
|
|
} else if (pass_style[0] == 8.0) {
|
|
|
|
f_color = texture(tex8, vec2(pass_style[1], pass_style[2]));
|
|
|
|
} else if (pass_style[0] == 9.0) {
|
|
|
|
f_color = texture(tex9, vec2(pass_style[1], pass_style[2]));
|
2019-09-11 01:21:58 +03:00
|
|
|
}
|
2019-05-13 02:40:52 +03:00
|
|
|
|
2019-05-13 04:05:14 +03:00
|
|
|
if (window[2] == 1.0) {
|
|
|
|
// The hatching should be done in map-space, so panning/zooming doesn't move the stripes.
|
|
|
|
// This is screen_to_map, also accounting for the y-inversion done by the vertex shader.
|
|
|
|
float map_x = (gl_FragCoord.x + transform[0]) / transform[2];
|
|
|
|
float map_y = (window[1] - gl_FragCoord.y + transform[1]) / transform[2];
|
2019-06-06 23:29:45 +03:00
|
|
|
if (mod(map_x + map_y, 2.0) <= 0.1) {
|
2019-05-13 04:05:14 +03:00
|
|
|
f_color = vec4(0.0, 1.0, 1.0, 1.0);
|
|
|
|
}
|
2019-06-06 23:29:45 +03:00
|
|
|
if (mod(map_x - map_y, 2.0) <= 0.1) {
|
2019-05-13 04:05:14 +03:00
|
|
|
f_color = vec4(0.0, 1.0, 1.0, 1.0);
|
|
|
|
}
|
2019-05-13 02:40:52 +03:00
|
|
|
}
|
2019-01-23 01:34:11 +03:00
|
|
|
}
|