mapbox / mapbox/mapbox-gl-js

[V3] colorRampTexture with NEAREST textureFilter

Open
#12,909 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api :memo: feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Motivation

The TextureFilter of colorRampTexture is now only fixed to 'LINEAR'.
But in some case, the user may wish to use 'NEAREST' for color palette, especially using 'step' expression for raster-color.
No color interpolation is needed arround threshold value.

with-proxy-web weathernews jp_smaphogen1314vs_hack_gis_mapbox_sample_v3_raster-color_radar_v3 0 0-beta 3 html(1280x960) (3)
with-proxy-web weathernews jp_smaphogen1314vs_hack_gis_mapbox_sample_v3_raster-color_radar_v3 0 0-beta 3 html(1280x960) (2)

The attached images area drawn by following paint properties.

    'raster-color': [
            'step',
            ['raster-value'],
            'transparent', 0.3,
            '#00DCEA', 2.0,
            '#0005B9', 8.0,
            '#FFF000', 16.0,
            '#F50100'
    ],
    'raster-color-mix': [255, 0, 0, 0],
    'raster-color-range': [0, 255],
    'raster-opacity': 0.8,

Design Alternatives

Design

adding new paint property like raster-color-resampling: "nearest" | "linear" ("linear" as default)
or use existing paint property raster-resampling for raster-color-ramp.

Mock-Up
Concepts
Implementation

change L130 of draw_raster.js

from

tex.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);

to

if(layer.paint.get('raster-color-resampling') === 'nearest') {
    tex.bind(gl.NEAREST, gl.CLAMP_TO_EDGE);
} else {
    tex.bind(gl.LINEAR, gl.CLAMP_TO_EDGE);
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read src/render/draw_raster.js around L130 first, where colorRampTexture is currently bound with LINEAR filtering. Confirm whether the new paint property or existing raster-resampling property should control sampling; done means NEAREST works for raster-color step expressions while LINEAR remains the default.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics, frontend, web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.