Repository navigation
fix(deck.gl-geotiff): draw 16-bit images in Firefox - #773
Merged
Merged
Conversation
…rmalized textures Firefox's WebGL2 has no EXT_texture_norm16, so r16unorm, rg16unorm and rgba16unorm uploads fail and 16-bit images draw nothing. When the device can't create one of those formats, upload the samples divided by 65535 as the matching 32-bit float format, so shaders read the same values. Sample nearest if the device can't filter float32. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron
commented
Oct 22, 2026
kylebarron
commented
Oct 22, 2026
kylebarron
left a comment
Member
Author
There was a problem hiding this comment.
👍 This was a lot cleaner than I was expecting it to be.
… docstring Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylebarron
added a commit
that referenced
this pull request
Oct 22, 2026
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]>
kylebarron
added a commit
that referenced
this pull request
Oct 22, 2026
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]>
kylebarron
added a commit
that referenced
this pull request
Oct 22, 2026
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]>
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]>
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before:

After:

Before:

After:

Note
This PR was written by Claude (Claude Code), not by @kylebarron.
Closes #648.
Firefox's WebGL2 doesn't support
EXT_texture_norm16, so it can't creater16unorm,rg16unormorrgba16unormtextures.COGLayeruploads every 16-bit unsigned COG in one of these formats, andMultiCOGLayerdoes the same for 16-bit bands such as Sentinel-2's. luma.gl doesn't check that the format is supported, so the upload fails without an error and nothing draws.When the device can't create one of these formats, both layers now divide the samples by 65535 and upload them as the matching 32-bit float format (
r32float,rg32floatorrgba32float). Shaders read the same 0-1 values either way, soLinearRescaleranges and nodata values work unchanged. If the device can't linearly filter float32 textures, they sample nearest instead. That check readsdevice.features.has("float32-filterable"), because luma.gl'sisTextureFormatFilterablereturns true for float formats on every WebGL2 device.Devices with
EXT_texture_norm16, such as Chrome, Edge and Safari, upload exactly as before. On devices without it:MultiCOGLayernow reports the bytes it uploads, so the tile cache counts the float32 size.Checked in Firefox 155 and Chrome 155 on macOS:
COGLayerdraw nothing on main and draw with this change. They still draw withOES_texture_float_linearhidden, sampling nearest.EXT_texture_norm16hidden: the Sentinel-2 example draws, and 98.2% of its pixels are identical to the nativer16unormoutput. The rest differ by at most 3/255.🤖 Written by Claude Code