Skip to content

Conversation

ansis
Copy link
Contributor

@ansis ansis commented Jan 28, 2016

This supports layers with extent != 4096 by converting all data to the maximum extent (8192) supported by our buffers. After the conversion, only the constant maximum extent is used.

fixes #1093

If a layer has an extent > 8192 it will lose precision when it is converted down to 8192. It will render ok, but it will be less exact when it is very overscaled. In order to increase the maximum extent, we would need to:

  • pack the line extrude direction bits in either the extrude or linesofar values instead of the position. The reduce precision in extrude or linesofar could cause issues.
    '(point.x << 1) | tx',
    '(point.y << 1) | ty'
  • use unsigned integers and translate everything by EXTENT / 2 before adding it to the buffers. And then using the posMatrix to translate it back in the shader.

I'm not sure whether either of those changes are worthwhile right now. 8192 seems high enough

👀 @jfirebaugh @lucaswoj @mourner

// round here because mapbox-gl-native uses integers to represent
// points and we need to do the same to avoid renering differences.
Math.round(point.x *= scale);
Math.round(point.y *= scale);
Copy link
Member

Choose a reason for hiding this comment

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

That doesn't look right. Math.round is immutable, so point will remain unrounded. Should be:

point.x = Math.round(point.x * scale);
point.x = Math.round(point.y * scale)

Also easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, definitely not right. Thanks for catching that, I'm sure it would have caused some headaches later on

@lucaswoj
Copy link
Contributor

Do you happen to know if this PR resolves mapbox/mapbox-gl-test-suite#75?

@@ -20,11 +21,10 @@ function Tile(coord, size, sourceMaxZoom) {
this.uses = 0;
this.tileSize = size;
this.sourceMaxZoom = sourceMaxZoom;
this.pixelRatio = EXTENT / size;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this used for? Is it expected that standard 4096 extent and 512 tile gives a 8.0 "pixel ratio"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was used for part of the conversion from pixels to tile units. 37e540f cleans up how that happens and removes tile.pixelRatio.

@ansis
Copy link
Contributor Author

ansis commented Jan 29, 2016

@mourner good call. When I rendered mapbox streets with a pattern for every line and fill (patterns use pixelsToTileUnits more) the total time fir pixelsToTileUnits was 0.20%. It's hard to measure how long the shared inline version takes for comparison, but I think it's small enough that it's fine. screen shot 2016-01-28 at 4 17 05 pm

@ansis
Copy link
Contributor Author

ansis commented Jan 29, 2016

Do you happen to know if this PR resolves mapbox/mapbox-gl-test-suite#75?

@lucaswoj nope, it doesn't resolve it. The fill test is slightly closer (0.0002 instead of 0.0005) but the bug is still there.

@ansis
Copy link
Contributor Author

ansis commented Jan 29, 2016

does anyone want to review this more or is it good to merge?

@jfirebaugh
Copy link
Contributor

LGTM!

ansis added 2 commits January 29, 2016 11:46
It converts all data to the maximum extent supported by our buffers and
only uses that constant extent everywhere else.
adds tile.pixelsToTileUnits(pixelValue, zoom)
and removes tile.pixelRatio
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.

Vector tile data rendered incorrectly if extent != 4096
4 participants