maplibre / maplibre-rs

Experimental Maps for Web, Mobile and Desktop
Apache License 2.0
1.34k stars 77 forks source link

Debug line width depends on zoom #230

Closed maxammann closed 1 year ago

maxammann commented 1 year ago

Currently the width of the debug lines depends on the zoom.

🤔 Expected Behavior

Lines should always have the same pixel-width on the screen.

😯 Current Behavior

The width changes.

💁 Possible Solution

Multiply the line width in the debug shader with a scaling factor: https://github.com/maxammann/maplibre-rs/blob/07bddd2a8c42f0cb906586f01eaaefb94dc34f7a/maplibre/src/render/shaders/tile.vertex.wgsl#L31

jackson211 commented 1 year ago

Would it be better to draw the line and the tile separately, don't change the width of the line until the tile refreshes? This can avoid recalculation on the line during zooming.

maxammann commented 1 year ago

The lines exist in "world space" that means that lines need to be scaled actually so they take the same amount of pixels independent of zoom.

This task is actually quite simple. We only need to multiply the line width a zoom_fraction which is already calculated in the code.