summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------mapbox-gl-js0
-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
5 files changed, 10 insertions, 3 deletions
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject de365184e13c08fb42bbd93a08abfc859829499
+Subproject 063fdebeaffbf6bc3ffff32233ed6248f42f3c5
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);