2020-02-15 01:28:25 +03:00
|
|
|
#version 300 es
|
|
|
|
|
|
|
|
precision mediump float;
|
|
|
|
precision mediump sampler2DArray;
|
2019-01-23 01:34:11 +03:00
|
|
|
|
2019-05-13 04:05:14 +03:00
|
|
|
// (x offset, y offset, zoom)
|
|
|
|
uniform vec3 transform;
|
2019-09-11 21:06:57 +03:00
|
|
|
// (window width, window height, _)
|
2019-05-13 04:05:14 +03:00
|
|
|
uniform vec3 window;
|
|
|
|
|
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-11-24 18:21:30 +03:00
|
|
|
// See actually_upload in drawing.rs to understand the different things encoded.
|
2019-12-04 02:19:44 +03:00
|
|
|
if (pass_style[0] == 100.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];
|
|
|
|
if (mod(map_x + map_y, 2.0) <= 0.1) {
|
|
|
|
f_color = vec4(0.0, 1.0, 1.0, 1.0);
|
|
|
|
} else if (mod(map_x - map_y, 2.0) <= 0.1) {
|
|
|
|
f_color = vec4(0.0, 1.0, 1.0, 1.0);
|
|
|
|
} else {
|
|
|
|
// Let the polygon with its original colors show instead.
|
|
|
|
discard;
|
|
|
|
}
|
|
|
|
} else if (pass_style[0] == 101.0) {
|
|
|
|
float map_x = (gl_FragCoord.x + transform[0]) / transform[2];
|
|
|
|
float map_y = (window[1] - gl_FragCoord.y + transform[1]) / transform[2];
|
|
|
|
if (mod(map_x + map_y, 2.0) <= 0.5) {
|
|
|
|
f_color = vec4(1.0, 1.0, 1.0, 1.0);
|
|
|
|
} else {
|
|
|
|
// Let the polygon with its original colors show instead.
|
|
|
|
discard;
|
|
|
|
}
|
2020-02-21 05:23:00 +03:00
|
|
|
} else {
|
2019-09-11 02:08:01 +03:00
|
|
|
f_color = pass_style;
|
2019-05-13 02:40:52 +03:00
|
|
|
}
|
2019-01-23 01:34:11 +03:00
|
|
|
}
|