abstreet/ezgui/src/assets/fragment_140.glsl

42 lines
1.4 KiB
Plaintext
Raw Normal View History

#version 300 es
precision mediump float;
precision mediump sampler2DArray;
// (x offset, y offset, zoom)
uniform vec3 transform;
// (window width, window height, _)
uniform vec3 window;
in vec4 pass_style;
out vec4 f_color;
void main() {
// See actually_upload in drawing.rs to understand the different things encoded.
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;
}
} else {
f_color = pass_style;
}
}