[V3] colorRampTexture with NEAREST textureFilter
Nobody has claimed this yet.
- 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.
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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