Skip to content

feat(deck.gl-geotiff): add a resampling prop to MultiCOGLayer - #775

Merged
kylebarron merged 3 commits into
mainfrom
kyle/multi-cog-resampling
Oct 22, 2026
Merged

kylebarron merged 3 commits into
mainfrom
kyle/multi-cog-resampling

Conversation

@kylebarron

@kylebarron kylebarron commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Before: linear, the default and main's only behavior

resampling-before-linear

After: nearest
resampling-after-nearest

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

kylebarron and others added 3 commits October 22, 2026 14:34
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]>
Lets the example switch MultiCOGLayer between linear and nearest
resampling, which shows both the smooth and the sharp-pixel view and
the rim that linear filtering draws at the scene's nodata edge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since #773, createBandTexture gives a band nearest filtering when the
device can't filter its format, such as a 16-bit band uploaded as
r32float without float32-filterable. Applying `resampling: "linear"` at
render time switched those textures back to linear, which leaves them
incomplete, so they read as 0. Check `isFilterable` there too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the feat label Oct 22, 2026

@kylebarron kylebarron left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kylebarron
kylebarron merged commit ba1beea into main Oct 22, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/multi-cog-resampling branch October 22, 2026 18:39
kylebarron added a commit that referenced this pull request Oct 22, 2026
…COGLayer (experimental) (#777)

> [!NOTE]
> This PR was written by Claude (Claude Code), not by @kylebarron.

`MultiCOGLayer` only uploaded `Uint8Array` and `Uint16Array` bands, so a
source with any other sample type, such as Int16 or Float32, threw
`Unsupported typed array type` on every tile.

Signed integers, `uint32` and floats now upload as `r32float`, converted
to `Float32Array` where needed, so the shader reads raw sample values.
Integer texture formats would need an integer sampler, which
`CompositeBands`' `sampler2D` can't read. Integers past 2^24 and
`Float64Array` samples round to float32.

These bands sample nearest where the device can't filter float32
textures: `createBandTexture` and the `resampling` prop from #775 both
check with `isFilterable` from #773. luma.gl's
`isTextureFormatFilterable` reports `r32float` as filterable on every
WebGL2 device. A linear sampler without `OES_texture_float_linear`
leaves the texture incomplete, so the scene draws black.

`uint8` and `uint16` bands still reach the render pipeline normalized to
0-1, while every other type keeps its raw value. The `renderPipeline`
docs now say so, since nodata values and rescale ranges depend on it.
They also mark the other types as experimental: that split is likely to
change so that every type arrives in the same units. The tile cache
counts the float32 bytes uploaded, which for Int16 is twice the source
size.

Thanks to @earlybard for #650, which this finishes. His two commits are
kept, followed by merges of main (resolved onto #773's
`createBandTexture`) and docs commits.

Checked in Chrome 155 on macOS with the Int16 scene from #650 (Digital
Earth Australia Sentinel-2 ARD, nodata -999):

- main: nothing draws, and every tile throws `Unsupported typed array
type: Int16Array`.
- This branch: the scene draws, and its nodata area is transparent.
- This branch with `OES_texture_float_linear` hidden: the scene draws,
sampling nearest. #650's own fallback drew it black.
- The Sentinel-2 example's `uint16` scene is unchanged.

Closes #650

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

---------

Co-authored-by: Dylan Jenkins <[email protected]>
Co-authored-by: Claude Fable 5.1 <[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.

1 participant