-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Polyline segments visibly overlap with alpha < 1 #1771
Comments
Compounding the effect, each line segment appears to have a round line cap and a square line cap. |
Ah, at first I thought this was a factor of line joins, which place a dot at the junction, but it does look like caps instead. Related: #1734 |
@incanus: Does this look like a relatively easy fix? It's one of two outstanding bugs that are preventing me shipping an app on MapboxGL (modifying the logo and attribution buttons being the other), and it'd be amazing if they could get rolled into the next release. Even just an ETA would be helpful - thanks! Let me know if there's a better channel for this. |
@jfirebaugh @ansis Do you have a sense how tough this fix is? |
I think we can experiment with the line joins/caps here to fix this without adverse effects. I will check it out. |
@incanus see mapbox/mapbox-gl-js#794 (comment) The quickest workaround is to use |
Test line is Line join for polyline annotations is set here: mapbox-gl-native/src/mbgl/map/map_context.cpp Lines 214 to 217 in 295ea08
Current ( Reverting to the default of So, the join problems are fixed, but the line is jagged, especially at sharp turns. This was the main reason I used Just for completeness, here's Looks better, but still problematic on sharp corners. Lastly, |
Experimenting with |
hmm, it looks like there are some tessellation bugs.
|
@tomtaylor Based on this, it doesn't appear to be a trivial fix. Would it help if we work a bit on #1734 and expose settings like the line join, so you can choose based on your data? Maybe you won't have sharp corners and a |
Here's a good patch for testing this by the way, using the default test shape of the hike up in northern Washington: diff --git a/ios/app/MBXViewController.mm b/ios/app/MBXViewController.mm
index 0024582..a19f8bd 100644
--- a/ios/app/MBXViewController.mm
+++ b/ios/app/MBXViewController.mm
@@ -347,12 +347,12 @@ mbgl::Settings_NSUserDefaults *settings = nullptr;
- (CGFloat)mapView:(__unused MGLMapView *)mapView alphaForShapeAnnotation:(MGLShape *)annotation
{
- return ([annotation isKindOfClass:[MGLPolygon class]] ? 0.5 : 1.0);
+ return ([annotation isKindOfClass:[MGLPolygon class]] ? 0.5 : 0.5);
}
- (UIColor *)mapView:(__unused MGLMapView *)mapView strokeColorForShapeAnnotation:(MGLShape *)annotation
{
- return ([annotation isKindOfClass:[MGLPolyline class]] ? [UIColor purpleColor] : [UIColor blackColor]);
+ return ([annotation isKindOfClass:[MGLPolyline class]] ? [UIColor blueColor] : [UIColor blackColor]);
}
- (UIColor *)mapView:(__unused MGLMapView *)mapView fillColorForPolygonAnnotation:(__unused MGLPolygon *)annotation
@@ -360,6 +360,11 @@ mbgl::Settings_NSUserDefaults *settings = nullptr;
return (annotation.pointCount > 3 ? [UIColor greenColor] : [UIColor redColor]);
}
+- (CGFloat)mapView:(__unused MGLMapView * __nonnull)mapView lineWidthForPolylineAnnotation:(__unused MGLPolyline * __nonnull)annotation
+{
+ return 10;
+}
+
- (void)mapView:(__unused MGLMapView *)mapView didChangeUserTrackingMode:(MGLUserTrackingMode)mode animated:(__unused BOOL)animated
{
UIImage *newButtonImage;
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp
index fa06a42..64d81a3 100644
--- a/src/mbgl/map/map_context.cpp
+++ b/src/mbgl/map/map_context.cpp
@@ -213,7 +213,8 @@ void MapContext::updateAnnotationTiles(const std::unordered_set<TileID, TileID::
// apply line layout properties to bucket
if (shapeStyle.is<LineProperties>()) {
- shapeBucket->layout.set(PropertyKey::LineJoin, ConstantFunction<JoinType>(JoinType::Round));
+ shapeBucket->layout.set(PropertyKey::LineJoin, ConstantFunction<JoinType>(JoinType::Miter));
+ shapeBucket->layout.set(PropertyKey::LineMiterLimit, ConstantFunction<float>(10));
}
// connect layer to bucket |
@ansis and @incanus Tesselation bug/line smudginess is very similar to what I've seen on Android devices (consistently reproducible on Samsung Nexus S). I am referring to the following issue. Lines on some Android device show the kind of smudginess that is included in the screenshots above. Smudginess gets worse upon pan/scroll. |
Hi @incanus and co, thanks a lot for looking at this. Yeah, I think I'm unlikely to have sharp corners or overlaps, so exposing some more options would help enough that I could get this out the door. Much appreciated. |
@tomtaylor We are looking at this directly in #1839 and are hoping to roll it into the next dev build, ideally today, with the milestone build later this week. |
@incanus great, thanks! |
@tomtaylor If I were to roll a custom build for you, would you be able to try it out? What are you using for install method? #1839 is looking pretty good in our testing. |
@incanus sure thing. I'm using CocoaPods, currently pointing at the podspec on master. If you could provide me with a different podspec URL, I could try that? |
@tomtaylor Give this one a shot:
|
@incanus that looks identical to me - no changes from the original issue. Are you sure that's pointing to the correct build? |
Oh, shoot, I forget to combine the simplification changes (included) with #1839 (not included). Sorry to waste your time — one sec. |
Ok @tomtaylor, trash your |
I'm wary to tweak the simplification for the specific case in light of affecting the general case. I also don't really want to expose simplification settings to the user as this gets complex. FWIW 888ae5e and 03c4ed7 just landed in master, so tonight's regular build will have the same effect as the custom build from #1771 (comment). |
Sure, understood. Thanks a lot - when the sprite customisation has landed I'll be able to ship this app. |
That just got merged — expect a build shortly. |
Going to move this off of the b3 milestone as we've made improvements here. We'll keep working on this — the end goal is zero overlap. |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
If you draw a MGLPolyline with an alpha < 1, the colour multiplies where segments overlap and it looks a little strange.
The text was updated successfully, but these errors were encountered: