Skip to content

Improve rendering pipeline#5

Merged
danielfdsilva merged 24 commits into
mainfrom
feature/color-pipeline
May 12, 2026
Merged

Improve rendering pipeline#5
danielfdsilva merged 24 commits into
mainfrom
feature/color-pipeline

Conversation

@danielfdsilva

@danielfdsilva danielfdsilva commented May 6, 2026

Copy link
Copy Markdown
Member

Summary

This replaces the old single vertex color extension with an explicit fragment pipeline built from small luma.gl shader modules. Filtering, rescaling, and coloring are separate stages with clear ordering.
The public API gains colorMode, filterMin / filterMax, rescaleMin / rescaleMax, optional shaderModules, and multi-texel value packing so cells can have more than four values.

Two GLSL hooks were added: HEALPIX_SELECT_VALUES and HEALPIX_RESCALE_VALUES, so callers can inject GLSL without forking the layer - useful for band math.

Api Changes

The user defines how many values sit behind each HEALPix cell using dimensions. Then through setting a colorMode the GPU knows whether the user wants:

  • a scalar value pulled through filter, rescale, and a color ramp;
  • the former plus a separate alpha channel;
  • or straight RGB or RGBA with no ramp.

By default the layer will consider the data to have one dimension and will be rendered as a scalar with a color ramp (default to gray unless provided). If there are more than 4 dimensions the user can provide custom glsl (passed to the layer as a shader module) to select the values they want.

const ndviSelector = {
  name: 'ndviSelector',
  inject: {
    'fs:HEALPIX_SELECT_VALUES': `\

// healpixValueAt is a utility function to select a value at a given index.

float nir = healpixValueAt(7);
float red = healpixValueAt(3);
float ndvi = (nir - red) / max(nir + red, 1e-6);
selectedValues = vec4(ndvi, 0.0, 0.0, 0.0);
`
  }
};

Whenever the color mode is set to scalar, the pipeline goes through a rescale function based on the rescaleMin / rescaleMax props, but the user can provide their own custom rescaling through the HEALPIX_RESCALE_VALUES hook.

flowchart LR
  subgraph GPU_fragment["Fragment shader — ordered stages"]
    V[Default selected values\n0-3]
    S[HEALPIX_SELECT_VALUES\ncustom selection hook]
    F[Filter\non scalar modes]
    R[Rescale\non scalar modes]
    H[HEALPIX_RESCALE_VALUES\ncustom rescale hook]
    C[Color\nLUT when scalar / RGB / RGBA]
    D[DECKGL_FILTER_COLOR\nnormal deckgl pipeline]
  end
  V --> S --> F --> R --> H --> C --> D
Loading

Demos

A demo site is now available at https://deck.gl-healpix.ds.io/examples/sandbox/

@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from c97c9b2 to 7a4cec7 Compare May 6, 2026 11:00
@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from 2e8bbab to b4a8e9f Compare May 6, 2026 11:59
@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from b4a8e9f to c619fa7 Compare May 6, 2026 12:04
@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from c619fa7 to e05e440 Compare May 6, 2026 12:11
@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from 80b2cae to e05e440 Compare May 6, 2026 13:45
@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from e05e440 to 8ad9576 Compare May 6, 2026 14:27
@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from 8ad9576 to 3625aaf Compare May 6, 2026 14:38
@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from 3625aaf to 04574e8 Compare May 6, 2026 14:44
@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from 04574e8 to 2baf498 Compare May 6, 2026 14:51
@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from 2baf498 to da03691 Compare May 6, 2026 14:54
The README and shader module comments are updated to emphasize that users extending the color pipeline via `fs:HEALPIX_SELECT_VALUES` or `fs:HEALPIX_RESCALE_VALUES` must write to the `selectedValues` `inout` parameter. Writing to the global `healpixSelectedValues` variable within these hooks would result in silent overwrites. Examples in the README are also corrected to reflect this guidance.
The specs are what's important for documenting
@danielfdsilva danielfdsilva force-pushed the feature/color-pipeline branch from da03691 to 53c7862 Compare May 6, 2026 14:58

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ooo I like the idea of having shared components for your examples

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I made developmentseed/deck.gl-raster#519 to do the same

Mobile GPUs enforce mediump int (±32767) strictly, while desktop drivers silently promote it to highp. The fragment shader's integer texture coordinate calculation (healpixCell * uTexelsPerCell) overflows mediump for datasets with more than ~32k cells, producing wrong texel lookups and corrupted colors. Fix by explicitly qualifying the critical integer variables in the shader module as highp int.
[ci skip]
@danielfdsilva danielfdsilva merged commit 8fd5b85 into main May 12, 2026
@danielfdsilva danielfdsilva deleted the feature/color-pipeline branch May 12, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants