summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-02-05 15:09:58 -0800
committerChris Loer <chris.loer@mapbox.com>2018-02-06 08:46:15 -0800
commit14db958ae51d3f7cf8fa802a72dfe6fdba7f8864 (patch)
tree8f613a9849e75f8d5edb81b8ec08ff0554d744aa /src/mbgl
parent671dfefc1e3fff5038a6d9cedc78daabffa5597f (diff)
downloadqtlocation-mapboxgl-14db958ae51d3f7cf8fa802a72dfe6fdba7f8864.tar.gz
[core] Account for overscaling in debug collision circles.
Fixes issue #11116. Port of GL JS issue $6041.
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/programs/collision_box_program.hpp1
-rw-r--r--src/mbgl/programs/uniforms.hpp1
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp3
-rw-r--r--src/mbgl/shaders/collision_circle.cpp8
4 files changed, 10 insertions, 3 deletions
diff --git a/src/mbgl/programs/collision_box_program.hpp b/src/mbgl/programs/collision_box_program.hpp
index 8d712a3df3..6e75adf36e 100644
--- a/src/mbgl/programs/collision_box_program.hpp
+++ b/src/mbgl/programs/collision_box_program.hpp
@@ -110,6 +110,7 @@ class CollisionCircleProgram : public Program<
gl::Uniforms<
uniforms::u_matrix,
uniforms::u_extrude_scale,
+ uniforms::u_overscale_factor,
uniforms::u_camera_to_center_distance>,
style::Properties<>>
{
diff --git a/src/mbgl/programs/uniforms.hpp b/src/mbgl/programs/uniforms.hpp
index 184f42e504..107c084918 100644
--- a/src/mbgl/programs/uniforms.hpp
+++ b/src/mbgl/programs/uniforms.hpp
@@ -55,6 +55,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(gl::TextureUnit, u_fadetexture);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_scale_a);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_scale_b);
MBGL_DEFINE_UNIFORM_SCALAR(float, u_tile_units_to_pixels);
+MBGL_DEFINE_UNIFORM_SCALAR(float, u_overscale_factor);
} // namespace uniforms
} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 04fcb2c3ab..9e493003c0 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -268,9 +268,10 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
gl::DepthMode::disabled(),
gl::StencilMode::disabled(),
parameters.colorModeForRenderPass(),
- CollisionBoxProgram::UniformValues {
+ CollisionCircleProgram::UniformValues {
uniforms::u_matrix::Value{ tile.matrix },
uniforms::u_extrude_scale::Value{ extrudeScale },
+ uniforms::u_overscale_factor::Value{ float(tile.tile.id.overscaleFactor()) },
uniforms::u_camera_to_center_distance::Value{ parameters.state.getCameraToCenterDistance() }
},
*bucket.collisionCircle.vertexBuffer,
diff --git a/src/mbgl/shaders/collision_circle.cpp b/src/mbgl/shaders/collision_circle.cpp
index f220586245..82ebbf05a0 100644
--- a/src/mbgl/shaders/collision_circle.cpp
+++ b/src/mbgl/shaders/collision_circle.cpp
@@ -26,7 +26,10 @@ varying vec2 v_extrude_scale;
void main() {
vec4 projectedPoint = u_matrix * vec4(a_anchor_pos, 0, 1);
highp float camera_to_anchor_distance = projectedPoint.w;
- highp float collision_perspective_ratio = 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance);
+ highp float collision_perspective_ratio = clamp(
+ 0.5 + 0.5 * (u_camera_to_center_distance / camera_to_anchor_distance),
+ 0.0, // Prevents oversized near-field circles in pitched/overzoomed tiles
+ 4.0);
gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
@@ -43,6 +46,7 @@ void main() {
)MBGL_SHADER";
const char* collision_circle::fragmentSource = R"MBGL_SHADER(
+uniform float u_overscale_factor;
varying float v_placed;
varying float v_notUsed;
@@ -68,7 +72,7 @@ void main() {
float extrude_scale_length = length(v_extrude_scale);
float extrude_length = length(v_extrude) * extrude_scale_length;
- float stroke_width = 15.0 * extrude_scale_length;
+ float stroke_width = 15.0 * extrude_scale_length / u_overscale_factor;
float radius = v_radius * extrude_scale_length;
float distance_to_edge = abs(extrude_length - radius);