Repository navigation
feat: Sprite-based colormap - #447
Merged
Merged
Conversation
Unifies Colormap shader module around sampler2DArray with a shipped matplotlib/rio-tiler sprite, so colormap switching becomes a uniform update rather than a texture rebind or fetch. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The loader helper returns a Texture directly, not { texture, index }.
Update the testing section to match and note that URL / ArrayBuffer
normalization paths need browser APIs beyond jsdom.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
decodeColormapSprite runs without a Device and can start at app boot; createColormapTexture is a synchronous GPU upload that pairs with it. Update the spec's API shape, consumer examples, testing notes, and files-changed list. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The shader now binds a sampler2DArray and samples one layer per fragment using a new colormapIndex uniform (i32, defaults to 0). The reversed uniform carries over unchanged. Callers upgrade by uploading their colormap LUT as a 1-layer 2D-array texture; the default colormapIndex means single-colormap call sites need no further change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Generator now writes a JSDoc block in front of each public export in colormap-names.ts so the constants appear with full hover docs in editors and in generated API docs. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Takes an already-decoded ImageData (from decodeColormapSprite or any other source the consumer brings) and uploads it to a sampler2DArray Texture with clamp-to-edge addressing. Validates width == 256 to catch mis-shaped sprites at upload time. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Accepts an ArrayBuffer, Uint8Array, or ImageBitmap and returns a Promise<ImageData>. No Device required, so callers can decode at app startup in parallel with device initialization and pair the result with createColormapTexture once the device is ready. Skip a string/URL overload to avoid disambiguating URL vs base64 vs data-URL inputs; consumers call fetch themselves and pass the bytes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Add COLORMAP_INDEX / ColormapName, createColormapTexture, and decodeColormapSprite / ColormapSpriteSource to the gpu-modules barrel, expose dist/gpu-modules/colormaps.png via a new subpath export, and copy the PNG into dist/ as part of the build. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Closed
This was referenced Apr 20, 2026
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.
Instead of loading colormap textures separately, one texture for every colormap, we now support sprite based colormaps. This means that all colormaps are saved into a single image, and then we switch the
y-indexto swap between colormaps with no overhead.The generated default colormap with 107 different colormaps is still just 16kb, and doesn't have a bundle size impact unless the user explicitly imports it.
Change list
Texture2DArrayto support many stacked colormaps as a single texture object