Rework texture formats so shaders read every data type in the same units

Aperta
#852 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Start with createBandTexture in packages/deck.gl-geotiff/src/multi-cog-layer.ts, inferRenderPipeline and FORMAT_TABLE in the GeoTIFF package, then follow the sampling and nodata modules. Compare the three options in the issue and trace how each data type reaches shader code. Done means one documented unit convention works for every data type, including signed integers and floats, across the affected pipelines.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

The units a shader reads a sample in depend on the raster's data type, and COGLayer's default pipeline renders only unsigned integers. This tracks reworking texture formats so that every data type reaches the shaders in the same units, and COGLayer can render signed integers and floats.

Today

MultiCOGLayer (createBandTexture):

  • uint8 and uint16 upload as r8unorm and r16unorm, so shaders read 0-1. Without EXT_texture_norm16, as in Firefox, uint16 goes to r32float divided by 65535, and stays 0-1 (#773).
  • Every other type uploads as r32float with raw values (#777). The renderPipeline docs mark these types as experimental, with units "likely to change".

COGLayer's default pipeline (inferRenderPipeline) handles only unsigned integers, and throws for signed integers and floats. The format table it uses (inferScalarKind, FORMAT_TABLE):

  • maps every unsigned type to a unorm format, so shaders read 0-1. There's no 32-bit unorm format, so uint32 throws.
  • maps signed integers to integer formats such as r16sint. CreateTexture samples with a sampler2D, which can't read integer textures.
  • maps floats to r32float, with raw values.
  • has uint entries, such as r8uint, that no input reaches.

The shader modules inherit the mix:

  • COGLayer scales nodata into 0-1 before FilterNoDataVal. For raw data, the same module takes the raw value.
  • LinearRescale's docs tell Sentinel-2 users to rescale 0-0.15 for reflectance 0-10000, because of r16unorm.
  • So a pipeline written for one data type gives wrong results for another, without an error.

The Zarr examples upload their own textures, as r32float with raw values.

Options

  1. Raw values for every data type (my pick). Shaders always read the data's own values, so nodata values, rescale ranges and filters are given in the data's units.
    • Storage can stay compact. uint8 and uint16 can stay in r8unorm and r16unorm, with the sampling module multiplying by 255 or 65535 to get the values back. Those formats can also be linearly filtered everywhere, which r32float needs float32-filterable for.
    • Signed integers and uint32 go to r32float, as MultiCOGLayer does today. #773's fallback would upload raw floats.
    • Breaking: the ranges in every uint8 and uint16 pipeline change, so this should land before 1.0.
  2. Normalized integers, raw floats, as today, but complete: signed integers as snorm (-1 to 1), or shifted into 0-1, as #180 did with a snorm-to-unorm module. Unsigned pipelines don't change, but floats and integers still differ, and the units of integer data depend on its bit width.
  3. Keep today's rules and document them, and add signed integers and floats to COGLayer's default pipeline only.

Related: #160 (nodata precision for floats), #772 (per-band uploads in COGLayer).

🤖 Written by Claude Code

Lingua principale
TypeScript
Stelle
240
Fork
34
Merge medio
17h 24m
PR unite (30g)
62

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di developmentseed/deck.gl-raster

Tutte le issue di developmentseed/deck.gl-raster

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.