Skip to content

fix: Allow MultiCOGLayer sampler to be overridden from default linear - #640

Closed
willjnz wants to merge 1 commit into
developmentseed:mainfrom
willjnz:sampler-multicoglayer
Closed

willjnz wants to merge 1 commit into
developmentseed:mainfrom
willjnz:sampler-multicoglayer

Conversation

@willjnz

@willjnz willjnz commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Related to #215 (comment). My data is UInt16 surface reflectance with nodata=0.

Can be simply used like

new MultiCOGLayer({
  ...
  bandSampler: { minFilter: "nearest", magFilter: "nearest" },
}),
Before (Linear sampler - blurred, with artifacts) After (Nearest sampler - sharp, clean)
Before 1 After 1
Before 2 After 2

@willjnz willjnz changed the title Allow MultiCOGLayer sampler to be overridden from default linear fix: Allow MultiCOGLayer sampler to be overridden from default linear Aug 25, 2026
@github-actions github-actions Bot added the fix label Aug 25, 2026
@earlybard

Copy link
Copy Markdown
Contributor

+1, we need this for MultiCOGLayer too. We composite Int16 reflectance and discard nodata with an exact-match filter; with linear sampling every scene edge and nodata hole gets a one-texel rim where the sentinel blends into real data and slips past the filter. Nearest fixes it. It also means r32float bands (#650) don't need OES_texture_float_linear.

@willjnz willjnz mentioned this pull request Oct 18, 2026
4 tasks done
kylebarron added a commit that referenced this pull request Oct 22, 2026
MultiCOGLayer creates its band textures itself, with a hardcoded linear
sampler, and offers no way to change it. Linear filtering defeats an
exact-match nodata filter: pixels next to nodata blend with the nodata
value, no longer match it, and draw as a rim.

`resampling: "linear" | "nearest"` (default "linear") picks the filter.
It is applied when each tile is rendered, not when its textures are
created, so changing it updates tiles that are already loaded without
fetching them again.

Based on #640 by @willjnz.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron added a commit that referenced this pull request Oct 22, 2026
MultiCOGLayer creates its band textures itself, with a hardcoded linear
sampler, and offers no way to change it. Linear filtering defeats an
exact-match nodata filter: pixels next to nodata blend with the nodata
value, no longer match it, and draw as a rim.

`resampling: "linear" | "nearest"` (default "linear") picks the filter.
It is applied when each tile is rendered, not when its textures are
created, so changing it updates tiles that are already loaded without
fetching them again.

Based on #640 by @willjnz.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron added a commit that referenced this pull request Oct 22, 2026
MultiCOGLayer creates its band textures itself, with a hardcoded linear
sampler, and offers no way to change it. Linear filtering defeats an
exact-match nodata filter: pixels next to nodata blend with the nodata
value, no longer match it, and draw as a rim.

`resampling: "linear" | "nearest"` (default "linear") picks the filter.
It is applied when each tile is rendered, not when its textures are
created, so changing it updates tiles that are already loaded without
fetching them again.

Based on #640 by @willjnz.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-authored-by: William Jones <[email protected]>
kylebarron added a commit that referenced this pull request Oct 22, 2026
> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

`MultiCOGLayer` creates its band textures itself and always filters them
linearly, with no way to change it. This adds `resampling?: "linear" |
"nearest"`, defaulting to `"linear"` (today's behavior).

Nearest shows the data's own pixels. It also matters with an exact-match
nodata filter such as `FilterNoDataVal`: linear filtering blends the
nodata value into the pixels next to it, so they no longer match it and
draw as a rim around nodata areas.

The filter is applied each time a tile is rendered, not only when its
textures are created. luma.gl stores the filter on each texture, and
`renderTile` runs for every loaded tile whenever the layer's props
change, so switching `resampling` updates loaded tiles without fetching
them again. A band whose format the device can't filter, such as a
16-bit band stored as `r32float` on a device without
`float32-filterable` (#773), stays nearest either way.

The Sentinel-2 example gets a Resampling selector.

This replaces #640's `bandSampler: SamplerProps` with a smaller API.
Thanks to @willjnz for the original PR, and to @earlybard for the nodata
case.

Closes #640
Ref #215

🤖 Written by [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: William Jones <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants