Skip to content

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

Closed
earlybard wants to merge 2 commits into
developmentseed:mainfrom
earlybard:feat/multi-cog-signed-float-bands
Closed

earlybard wants to merge 2 commits into
developmentseed:mainfrom
earlybard:feat/multi-cog-signed-float-bands

Conversation

@earlybard

@earlybard earlybard commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Hello

First up, thanks for supporting this library and sorry for the 3-PR assault! Happy to work with you on any of these. I have a little COG mosaic viewer running that depends on these 3 PRs to run perfectly.

What I am changing

MultiCOGLayer only knows how to use Uint8Array and Uint16Array, so point it at an Int16 or Float32 COG and every tile throws Unsupported typed array type. I'm working with Int16 images with nodata -999.

Signed ints, Uint32Array and floats all now upload as r32float, converting to Float32Array where needed, so the shader sees raw sample values.

A float texture only filters linearly where the device supports it (OES_texture_float_linear in WebGL, missing on about half of iOS and a quarter of Android WebGL2 contexts per web3dsurvey). Without it the texture is incomplete and reads as zeros, so createBandTexture asks device.isTextureFormatFilterable and falls back to a nearest sampler.

How you can test it

const scene =
  "https://dea-public-data.s3.ap-southeast-2.amazonaws.com/baseline/ga_s2am_ard_3/55/HFB/2026/01/03/20260103T012735/ga_s2am_nbart_3-2-1_55HFB_2026-01-03_final_band";
new MultiCOGLayer({
  id: "s2",
  sources: {
    red: { url: `${scene}04.tif` },
    green: { url: `${scene}03.tif` },
    blue: { url: `${scene}02.tif` },
  },
  composite: { r: "red", g: "green", b: "blue" },
  renderPipeline: [
    { module: FilterNoDataVal, props: { value: -999 } },
    { module: LinearRescale, props: { rescaleMin: 0, rescaleMax: 3000 } },
  ],
});

On main every tile fails; with this the scene renders.

Related Issues

#180 is the COGLayer side of the same problem, via snorm textures and a rescale module. This only touches MultiCOGLayer, and uses floats because its pipeline works on raw values. Happy to change tack if you'd rather they share a format table.

AI disclosure: written with Claude Code as a code assistant, reviewed by me.

@github-actions github-actions Bot added the feat label Sep 17, 2026
@earlybard
earlybard force-pushed the feat/multi-cog-signed-float-bands branch 3 times, most recently from 5f0e175 to cf0ea26 Compare September 17, 2026 08:30
@earlybard
earlybard marked this pull request as ready for review September 17, 2026 08:37
@earlybard
earlybard force-pushed the feat/multi-cog-signed-float-bands branch from a57ea76 to a288c7e Compare September 22, 2026 05:52
…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]>
@earlybard
earlybard force-pushed the feat/multi-cog-signed-float-bands branch from a288c7e to 13eedf2 Compare October 21, 2026 23:28
…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]>
@earlybard
earlybard force-pushed the feat/multi-cog-signed-float-bands branch from 13eedf2 to 8b03f0d Compare October 21, 2026 23:32
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