11 static constexpr
const char* vertex = R
"(layout (location = 0) in vec2 a_pos;
12 layout (location = 1) in vec2 a_anchor_pos;
13 layout (location = 2) in vec2 a_extrude;
14 layout (location = 3) in vec2 a_placed;
15 layout (location = 4) in vec2 a_shift;
17 uniform mat4 u_matrix;
18 uniform vec2 u_extrude_scale;
19 uniform float u_camera_to_center_distance;
25 vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);
26 highp float camera_to_anchor_distance = projectedPoint.w;
27 highp float collision_perspective_ratio = clamp(
28 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),
29 0.0, // Prevents oversized near-field boxes in pitched/overzoomed tiles
32 gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
33 gl_Position.xy += (a_extrude + a_shift) * u_extrude_scale * gl_Position.w * collision_perspective_ratio;
35 v_placed = a_placed.x;
36 v_notUsed = a_placed.y;
39 static constexpr
const char* fragment = R
"(
47 // Red = collision, hide label
48 fragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha;
50 // Blue = no collision, label is showing
52 fragColor = vec4(0.0, 0.0, 1.0, 0.5) * alpha;
55 if (v_notUsed > 0.5) {
56 // This box not used, fade it out
@ OpenGL
The OpenGL API backend.
BuiltIn
This enum is used with the ShaderSource template to select source code for the desired program and gr...
Select shader source based on a program type and a desired graphics API.