mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-29 17:34:58 +03:00
Make z-order changes work on web too, restoring tooltips
This commit is contained in:
parent
982b0bc194
commit
6cce3b1946
@ -5,7 +5,7 @@ precision mediump sampler2DArray;
|
||||
|
||||
// (x offset, y offset, zoom)
|
||||
uniform vec3 transform;
|
||||
// (window width, window height, _)
|
||||
// (window width, window height, z value)
|
||||
uniform vec3 window;
|
||||
|
||||
in vec4 pass_style;
|
||||
|
@ -7,20 +7,33 @@ uniform vec3 transform;
|
||||
// (window width, window height, z value)
|
||||
uniform vec3 window;
|
||||
|
||||
layout (location = 0) in vec2 position;
|
||||
layout (location = 0) in vec3 position;
|
||||
layout (location = 1) in vec4 style;
|
||||
out vec4 pass_style;
|
||||
|
||||
void main() {
|
||||
pass_style = style;
|
||||
|
||||
float zoom = transform[2];
|
||||
|
||||
// This is map_to_screen
|
||||
float screen_x = (position[0] * transform[2]) - transform[0];
|
||||
float screen_y = (position[1] * transform[2]) - transform[1];
|
||||
// Translate that to clip-space or whatever it's called
|
||||
float screen_x = (position[0] * zoom) - transform[0];
|
||||
float screen_y = (position[1] * zoom) - transform[1];
|
||||
|
||||
// Translate position to normalized device coordinates (NDC)
|
||||
float x = (screen_x / window[0] * 2.0) - 1.0;
|
||||
float y = (screen_y / window[1] * 2.0) - 1.0;
|
||||
|
||||
// largest absolute value for layer base z values in drawing.rs (i.e.
|
||||
// MAPSPACE_Z vs. TOOLTIP_Z)
|
||||
float z_range = 2.0;
|
||||
// we increment z up to 1.0 to affect ordering within a layer, so consider
|
||||
// that when scaling z to NDC too
|
||||
float z_scale = z_range + 1.0;
|
||||
|
||||
float z = (position[2] + window[2]) / z_scale;
|
||||
|
||||
|
||||
// Note the y inversion
|
||||
gl_Position = vec4(x, -y, window[2], 1.0);
|
||||
gl_Position = vec4(x, -y, z, 1.0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user