mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

Stops vs Literal value: Icon size is different for same value.

Open bewithjonam opened this issue 8 years ago • 7 comments

Symbol layer with

   "icon-size": 0.27,
   "icon-size": {
      type: 'interval',
      default: iconSize,
      property: "__resize_by__",
      stops: [[0, iconSize]]
    },

are rendering images at different size.

~~jsfiddle~~ jsfiddle explaining the issue. In the fiddle I render a icon at size 0.27 and then after 2 seconds I set the same size using stops.

Expected Behavior

It should render with the same size

Actual Behavior

When using stops, it is rendering smaller than when given a literal value

bewithjonam avatar Aug 01 '18 15:08 bewithjonam

Your JSFiddle doesn't seem to work — I see no icons on the map there.

mourner avatar Aug 01 '18 15:08 mourner

@mourner New jsfiddle with a large png, showing the issue.

https://jsfiddle.net/bewithjonam/Lf1prz26/12/

If I am not wrong, the issue happens only on decimal icon-sizes. And the previous image that i used from the sprite was very small.

bewithjonam avatar Aug 01 '18 18:08 bewithjonam

I think the same problem causes my issue: https://github.com/mapbox/mapbox-gl-js/issues/7017

zoltan-mihalyi avatar Aug 01 '18 18:08 zoltan-mihalyi

Yes, this has the same underlying cause as #7017: to minimize vertex buffer memory, data-driven icon-size values are packed into a Uint16 vertex attribute component with a precision limit of 0.1 (the floating point value is multiplied by 10 when populating the vertex array, converted to an integer, and divided by 10 in the shader).

@ChrisLoer @ansis Should we just switch a_data to use Float32?

jfirebaugh avatar Aug 01 '18 21:08 jfirebaugh

Float32 is an option but we could also just multiply and divide by 256 instead if we don't want to use more bytes per vertex. We don't really have any memory benchmarks right now so this is hard to measure how significant the change would be

ansis avatar Aug 02 '18 17:08 ansis

I removed the jsfiddle accidently. Here is an equivalent one: http://jsfiddle.net/bewithjonam/41g8jwco/

bewithjonam avatar Aug 10 '18 09:08 bewithjonam

Is it possible to use 256 instead of 10?

zoltan-mihalyi avatar Aug 10 '18 11:08 zoltan-mihalyi