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

maybe switch to quads for icons #491

Closed
ansis opened this issue Jun 25, 2014 · 3 comments · Fixed by #505
Closed

maybe switch to quads for icons #491

ansis opened this issue Jun 25, 2014 · 3 comments · Fixed by #505
Assignees

Comments

@ansis
Copy link
Contributor

ansis commented Jun 25, 2014

Icons and glyphs are very similar. The only differences are where their bitmap comes from and whether they are sdfs. sdf icons will also be supported at some point. Both are sometimes aligned with the screen (horizontal labels and icons) and sometimes rotated with the map (one way icons, road labels).

Icons and glyphs are currently drawn differently. I think they should be drawn the same way. Should icons be drawn with quads? or if drawing with gl_point is better, should we change how glyphs are drawn?

  • gl_point needs one vertex per element, quads have four
  • for items that rotate with the map, gl_point needs to shade twice as many fragments
  • non-rectangular items waste fragments when drawn with gl_point
  • gl_point limits size to 32px. 22px for rotated items

This would be nice to handle as part of implementing mapbox/mapbox-gl-style-spec#67

@kkaefer

@kkaefer
Copy link
Member

kkaefer commented Jun 25, 2014

It looks like there are good reasons for both. The current icon shader uses 8 bytes (vertex) + 2 bytes (element) = 10 bytes per POI icon, while the text shader uses (4 * 16 bytes (vertex) + 6 * 2 bytes (element) = 76 bytes per Glyph. We could reduce the usage for icon-specific buffers to 12 or even 8 bytes/vertex. While this sounds really large, it might still be okay; a thousand icons only take up 76KB of buffer space.

What's more important, moving the icon dimensions to the buffer allows us to draw icons of different size with one draw command, which is probably more efficient than saving a little buffer space.

BTW, I don't think combining icons and glyphs is possible in the short term, because the shaders are vastly different: we need to do the SDF alpha testing and linear interpolation for glyph images, but don't want linear interpolation, and only straight texture mapping for icons.

@ansis
Copy link
Contributor Author

ansis commented Jun 25, 2014

BTW, I don't think combining icons and glyphs is possible in the short term

The combining suggested in the other issue is just processing them together, in the same render type, to solve placement issues. They would still be drawn with two draw calls. The fragment shaders would be different, but vertex shaders would be identical. The switch will make fading points possible.

I don't think we need to worry about performance drawing icons with quads because there are way more glyphs already being drawn with quads. We can check later once we have a good way of benchmarking.

@kkaefer
Copy link
Member

kkaefer commented Jul 7, 2014

native issue: mapbox/mapbox-gl-native#356

stepankuzmin pushed a commit that referenced this issue Jun 21, 2023
* render test to capture issue

* forgotten to move back caculations to fragment shader

* review fixes and opacity multiplied in fragment now
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 a pull request may close this issue.

3 participants