Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text-pitch-alignment #2668

Merged
merged 4 commits into from
Jun 11, 2016
Merged

text-pitch-alignment #2668

merged 4 commits into from
Jun 11, 2016

Conversation

yhahn
Copy link
Member

@yhahn yhahn commented Jun 4, 2016

Implements full support for the proposed text-pitch-alignment property.

+ rotation=map rotation=viewport
pitch=map d a
pitch=viewport c b

How it works

  • Adds passing of individual glyph angles as a vertex shader attribute
  • Pass map pitch, bearing, aspect_ratio (for adjusting pitched angle) to SDF shader
  • The SDF vertex shader is now responsible for rotating quads

Backlog

cc @lucaswoj @mollymerp @ansis

@yhahn yhahn self-assigned this Jun 4, 2016
addVertex(vertexArray, anchorPoint.x, anchorPoint.y, bl.x, bl.y, tex.x, tex.y + tex.h, minZoom, maxZoom, placementZoom);
addVertex(vertexArray, anchorPoint.x, anchorPoint.y, br.x, br.y, tex.x + tex.w, tex.y + tex.h, minZoom, maxZoom, placementZoom);
// Encode angle of line together with symbol.alongLine
var placementAngleLine = symbol.curved ? 0 : 1 + Math.round(((angle % Math.PI) / Math.PI) * 255);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

angleLine name implies a line rather than angle, perhaps lineAngle would be better?

@lucaswoj
Copy link
Contributor

lucaswoj commented Jun 6, 2016

I'm not sold on this PR from a map-design-asthetic standpoint. All the labels should be "billboards" or none of them should be.

screen shot 2016-06-06 at 3 48 34 pm

For reference, here is a screenshot that demonstrates how Apple Maps draws labels.

___nh_ch___p_m__n_h__nh_2016-06-06_l__c_15 50 04_720

(some wordage and screenshots from @1ec5)

@PaulZed
Copy link

PaulZed commented Jun 6, 2016

@lucaswoj Can you justify why it's inherently better to be consistent? I'm not sure what the objection is if unskewing the text increases readability. Roads like beachmont are much easier to resolve when they're unskewed when compared to their skewed version. There also isn't really a clear way to unskew linearly independent glyphs using this strategy, so until we discover a better solution I agree with not attempting to unskew them.

@dpieri
Copy link

dpieri commented Jun 8, 2016

I agree with @lucaswoj on this one. The mixture of skewed and not skewed labels really messes with perspective and makes the map look distorted. I think it adds to the cognitive load required to orient yourself in 3D when looking at the map.

@yhahn
Copy link
Member Author

yhahn commented Jun 8, 2016

Per @lucaswoj + @1ec5's feedback I took another pass at unskewing curved labels. Overall the new approach is much cleaner:

  • No codepath difference between how straight/curved line labels are rendered (no more curved vs straight heuristic),
  • Visual result is pretty good

But there is one major caveat -- the way quads are positioned for curved labels isn't forgiving to this approach beyond around 45 degrees of pitching (and our general strategy for placing glyphs along curves has some 😖 conflicts with placement on a pitched map that I can capture in a separate ticket). Also worth noting that most other map apps/renderers don't allow extreme pitching even beyond 30 degrees or so.

That said I definitely think this is the approach to go with right now and we can circle back around to a larger refactor around curved labels if needed in the future.

master unskew v2
unskew-master unskew-v2

Churning through the rest of the backlog above and native port next before we land on the style spec question.

@lucaswoj
Copy link
Contributor

lucaswoj commented Jun 8, 2016

This is awesome @yhahn! Even with the caveats, I feel 😍 about merging this from map-design-asthetic standpoint. Let me know if I can help with the remaining technical backlog.

@PaulZed
Copy link

PaulZed commented Jun 8, 2016

That example is pretty compelling :). You can definitely see the difference in glyph rotation for curved roads but it's quite minor. My only concern is that without some sort of curvature heuristic there might be cases where the difference between non-linearly placed glyphs is more severe.

yhahn added a commit to mapbox/mapbox-gl-native that referenced this pull request Jun 8, 2016
@mourner
Copy link
Member

mourner commented Jun 9, 2016

@yhahn great work! One question though — placement/collision detection are not affected by unskewing here, so in some cases, labels can appear slightly colliding or protruding beyond the end of a line, right? Do we want to account for that, or is that a subject to follow-up PRs?

@yhahn
Copy link
Member Author

yhahn commented Jun 9, 2016

so in some cases, labels can appear slightly colliding or protruding beyond the end of a line, right?

@mourner yes, especially if the pitch angle is very high. Designers can adjust for this pretty well right now as a stopgap.

I think this is something we can address in a further iteration/concepting -- OTOH I think to account for pitch when calculating collision it'll require doing redoplacement on map x/y movement in addition to just rotation.

@yhahn yhahn force-pushed the unskew branch 2 times, most recently from 9fb7000 to 6f5df92 Compare June 9, 2016 16:38
@yhahn yhahn changed the title [notready] Unskew line labels on pitched maps [notready] text-pitch-alignment Jun 9, 2016
@yhahn
Copy link
Member Author

yhahn commented Jun 9, 2016

OP updated as this PR has evolved. Will hop next to updating native and then getting a full set of the rotate/pitch permutations in place in the render tests.

@yhahn yhahn changed the title [notready] text-pitch-alignment text-pitch-alignment Jun 10, 2016
@yhahn
Copy link
Member Author

yhahn commented Jun 10, 2016

@lucaswoj I think this ready for your review!

I've also reviewed the current benchmarks and manually tested the debug page without seeing any noticeable difference in user experience. Let me know if you think we should take on adding some more systematic benchmarks for this work specifically.

@lucaswoj
Copy link
Contributor

Amazing work @yhahn! :shipit:

yhahn added a commit to mapbox/mapbox-gl-native that referenced this pull request Jun 11, 2016
* First pass at port of mapbox/mapbox-gl-js#2668

* RotationAlignmentType => AlignmentType

* Handle undefined default value for text-pitch-alignment and implement inheritance for this value from text-rotation-alignment

* Update dependencies

* Move handling fo undefined default value out of camelize functions
@yhahn yhahn merged commit 73f102a into master Jun 11, 2016
@yhahn yhahn deleted the unskew branch June 11, 2016 03:05
blanchg pushed a commit to blanchg/mapbox-gl-js that referenced this pull request Jun 13, 2016
* First pass at unskewed line labels on pitched maps

* Unskew curved labels as well

* Inherit default value of text-pitch-alignment from text-rotation-alignment.

* Update dependencies
lucaswoj pushed a commit that referenced this pull request Jun 13, 2016
* First pass at unskewed line labels on pitched maps

* Unskew curved labels as well

* Inherit default value of text-pitch-alignment from text-rotation-alignment.

* Update dependencies
davidtheclark pushed a commit that referenced this pull request Jun 15, 2016
* First pass at unskewed line labels on pitched maps

* Unskew curved labels as well

* Inherit default value of text-pitch-alignment from text-rotation-alignment.

* Update dependencies
davidtheclark pushed a commit that referenced this pull request Jul 1, 2016
* First pass at unskewed line labels on pitched maps

* Unskew curved labels as well

* Inherit default value of text-pitch-alignment from text-rotation-alignment.

* Update dependencies
@yhahn yhahn mentioned this pull request Jul 31, 2016
2 tasks
@ansis ansis mentioned this pull request May 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants