Skip to content

feat(deck.gl-geotiff): render signed integer and float bands in MultiCOGLayer (experimental) - #777

Merged
kylebarron merged 8 commits into
mainfrom
kyle/multi-cog-signed-float-bands
Oct 22, 2026
Merged

kylebarron merged 8 commits into
mainfrom
kyle/multi-cog-signed-float-bands

Conversation

@kylebarron

@kylebarron kylebarron commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

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):

Closes #650

🤖 Written by Claude Code

earlybard and others added 5 commits October 22, 2026 10:27
…COGLayer

createBandTexture accepted Uint8Array and Uint16Array only, so a
MultiCOGLayer over Int16 or Float32 COGs threw on its first tile. Signed
integers, Uint32Array and floats now upload as r32float, converted to
Float32Array where needed, so the shader samples raw values. The integer
texture formats would need an isampler2D/usampler2D the pipeline's
sampler2D modules cannot read, and no normalised format holds a signed
16-bit sample without EXT_texture_norm16.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…nnot filter them

WebGL treats a float texture under a linear sampler as incomplete unless
OES_texture_float_linear is present, and every fetch from an incomplete
texture returns zeros. The extension is missing on roughly half of iOS
and a quarter of Android WebGL2 contexts, so r32float bands rendered
black there. Ask the device before choosing the sampler.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#773 rewrote createBandTexture for devices without r16unorm. Keep its
flow (resolveTextureFormat, isFilterable, and the uploaded byte length)
and add this branch's r32float upload for every other typed array.

That drops this branch's sampler fallback. It asked
device.isTextureFormatFilterable, which luma.gl answers true for
r32float on every WebGL2 device, so float bands still sampled linear
without OES_texture_float_linear and drew black. isFilterable checks the
float32-filterable feature instead. The uploaded byte length also makes
the tile cache count Int16 bands at their float32 size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
uint8 and uint16 bands reach the render pipeline normalized to 0-1,
while signed integer, uint32 and float bands keep their raw values, so a
FilterNoDataVal value or LinearRescale range depends on the band's type.
Document that on renderPipeline, and update the dev doc that still said
createBandTexture only handled uint8 and uint16.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in #775's `resampling` prop. Its render-time filter check uses
isFilterable on each texture, so the r32float bands from this branch
stay nearest on devices that can't filter floats. Both sides appended a
describe block to the MultiCOGLayer tests; keep both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread dev-docs/multi-resolution-status.md Outdated
**Status**: Works for every single-band type; multi-band textures are not handled.

`createBandTexture` supports `r8unorm` (Uint8Array) and `r16unorm` (Uint16Array). Multi-band textures, float32, and other formats are not yet handled. Should eventually use `inferTextureFormat` from `texture.ts`.
`createBandTexture` uploads `Uint8Array` as `r8unorm` and `Uint16Array` as `r16unorm` (or 0-1 `r32float` on devices without `EXT_texture_norm16`). Every other typed array uploads as `r32float` with raw values. `inferTextureFormat` from `texture.ts` doesn't fit: its integer formats need an integer sampler, which `CompositeBands` doesn't use.

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.

createBandTexture uploads Uint8Array as r8unorm and Uint16Array as r16unorm (or 0-1 r32float on devices without EXT_texture_norm16). Every other typed array uploads as r32float with raw values.

I'm still unsure about whether this is the right approach.

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.

It feels messy to create an API like this.

Perhaps we could merge it but mark it as experimental, somehow, signaling that it's likely to change in the future?

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.

Let's mark it as experimental and merge

…perimental

uint8 and uint16 bands reach the render pipeline normalized to 0-1, and
every other type keeps its raw value. That split is likely to change so
that every type arrives in the same units, so say in the renderPipeline
docs that the other types are experimental rather than presenting their
units as settled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron kylebarron changed the title feat(deck.gl-geotiff): render signed integer and float bands in MultiCOGLayer feat(deck.gl-geotiff): render signed integer and float bands in MultiCOGLayer (experimental) Oct 22, 2026
Apply the review suggestion: give the r16unorm fallback and the
experimental note their own paragraphs, and bold "experimental".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n paragraph

Apply the review suggestion, and bold "experimental".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylebarron
kylebarron merged commit 63918a5 into main Oct 22, 2026
3 checks passed
@kylebarron
kylebarron deleted the kyle/multi-cog-signed-float-bands branch October 22, 2026 19:12
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