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

Add style-spec option to specify interpolation mode for raster-style sources #4450

Closed
CrokinoleMaster opened this issue Mar 18, 2017 · 14 comments · Fixed by #6411
Closed

Add style-spec option to specify interpolation mode for raster-style sources #4450

CrokinoleMaster opened this issue Mar 18, 2017 · 14 comments · Fixed by #6411
Assignees
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏 good first issue needs discussion 💬

Comments

@CrokinoleMaster
Copy link
Contributor

mapbox-gl-js version: v0.34.0

Steps to Trigger Behavior

  1. create an ImageSource using a nice pixelated image
  2. add raster layer using created source

Expected Behavior

have an option to use gl.NEAREST so that my image is pixelated rather than blurry.

Actual Behavior

My nice pixelated image is now a blurry and ugly because ImageSource._prepareImage uses gl.LINEAR :(
https://github.com/mapbox/mapbox-gl-js/blob/master/src/source/image_source.js#L157-L158

@andrewharvey
Copy link
Collaborator

andrewharvey commented Mar 19, 2017

Something for the GL Style Spec raster layer.

CartoCSS exposed this as the raster-scaling property.

Could be useful for maps like weather radars, mobile cell coverage too:

idr033

selection_494

@CrokinoleMaster
Copy link
Contributor Author

@andrewharvey yes! that's exactly what I meant.

@anandthakker anandthakker added cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏 labels Mar 21, 2017
@anandthakker anandthakker changed the title ImageSource should allow gl.NEAREST filter as an option Add style-spec option to specify interpolation mode for raster-style sources Mar 21, 2017
@anandthakker
Copy link
Contributor

Updated the title to reflect a style-spec feature request (as @andrewharvey noted).

cc @mapbox/gl

@CrokinoleMaster
Copy link
Contributor Author

the texture is created in the source and not in the layer, so the source cannot know the layer paint properties when it creates the texture.

@rohitrameshrao
Copy link

Exactly what I am looking for. I am unable to use mapbox/GL for a lot of annotation jobs that require pixel-level accuracy.

Can we expect this anytime soon?

@kkaefer
Copy link
Member

kkaefer commented Feb 12, 2018

To implement this, set the texture scale mode to gl.NEAREST, and expose this as an option in the style spec.

@rohitrameshrao
Copy link

@kkaefer Can you help with where can I change the texture scale mode to gl.nearest? I don't mind hard-coding this in my js file for now.

@andrewharvey
Copy link
Collaborator

@rohitrameshrao I believe it's the gl.LINEAR at

this.texture.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);

@rohitrameshrao
Copy link

Thanks @andrewharvey! I tried changing it and building it. The map is still not pixelated! :/

@andrewharvey
Copy link
Collaborator

andrewharvey commented Mar 27, 2018

@rohitrameshrao that place in the code sets it for Image sources, if you're using a raster tile source then you'll also need to set it around

if (tile.texture) {

UPDATE: ^ isn't right, I'm working on a PR which should solve this.

@andrewharvey
Copy link
Collaborator

@rohitrameshrao take a look at #6411 for the delta to get it working, at the moment I can only work out how to hardcode an Image source as either linear or nearest filtering, so if you need an urgent solution you could just use the current PR which has it hardcoded...

@andrewharvey
Copy link
Collaborator

@rohitrameshrao from my testing #6411 is working well, would appreciate if you could test it out too.

@rohitrameshrao
Copy link

@andrewharvey Sure! Will test this in the next couple of days and let you know. Thanks!

@CrokinoleMaster
Copy link
Contributor Author

Awesome thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏 good first issue needs discussion 💬
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants