-
-
Notifications
You must be signed in to change notification settings - Fork 932
Hypsometric Tint from terrain-RGB tiles #5913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@larsmaxfield I haven't added any support for dynamically modifying the ramp. Can you tell me more about how you would expect to use that? Would you be using |
|
I would expect to modify the ramp similar to how I can change existing layer paint properties. For example, to tighten the range of a monochrome colorramp via const monochrome = [
"interpolate",
["linear"],
["elevation"],
0.0, 'black',
0.1, 'black',
3000, 'white',
3001, 'white'
];
...
monochrome[5] = 2000; // Tighten range from 0.1–3000 to 2000–2100
monochrome[7] = 2100;
map.setPaintProperty('hyspometric-layer', 'color-relief-color': monochrome);Or is this already possible? |
|
@larsmaxfield I've added the capability to modify the colorramp dynamically using My demo now uses |
|
Excellent. And indeed very fast. Thank you! |
|
Added a few comments: |
…p() and getColorRamp()
|
Looking good, thanks for taking the time to make these changes! I'm hopeful our days having to consider WebGL 1 are numbered, I encourage you to join the discussion about this at our next Web meeting. I'll defer final approval to @HarelM. |
|
Looks good overall. Added a final question but approved otherwise... |
* Basic color relief layer working, with a hardcoded colormap * use texture for color-relief colormap * add color relief benchmark * fix border rendering error and ugliness * do lookup table in shader * fix merge error * fix initialization of _featureFilter with stytle-spec update (global state addition) * remove dead code (pulling colormap from texture) * remove more dead code related to rendering color relief from texture * add unit tests for ColorReliefStyleLayer * add render tests and global opacity handling * Add a color relief example * add render test with color relief and hillshade * fix lint * fix benchmark and update changelog * updat to use latest version of style spec * add "hypsometric" to spelling list * update expectedBytes * improve function name * remove "as any", simplify colorramp creation, add comment * remove colorramp requirement length = 2^N + 1 * Remap the color-relief color ramp if the length exceeds the WebGL capabilities. * add unit test for getColorRamp() * handle empty and single-color color ramps * account for presence of other uniforms in calculation of maxLength for color ramp * return arrays in _updateColorRamp() * sinplify getColorRamp() * add (messy) type to createColorReliefLayerSpec() argument * fix colorRampLength * add color relief layer benchmarks * use defined type * add DEMData::pack() function and unit tests * version of color relief that uses textures instead of uniforms for colorramp * get the right size limit for color ramp * update expectedBytes * fix off-by-one error * use texture lookup instead of shader interpolation * function nameing and comment formating * defer color ramp creation until getColorRamp * update unit tests * remove unneeded shader #define * fix colorRampLength calculation * use first available textures * fix expectedBytes * enable color ramp to be dynamically changes using map.setPaintProperty() * reduce indentation * remove unneeded member variable colorRamp and combine _createColorRamp() and getColorRamp() * fix build * add RGBAImage::setPixel() * fix lint --------- Co-authored-by: Harel M <[email protected]>

Resolves #5666 (Hypsometric Tint from terrain-RGB tiles).
Demo here: https://nathanmolson.github.io/color_relief
The shader uses a binary search to find the adjacent color stops from the color ramp, which means that larger color palettes take longer to render (O(log(n))).
While #5742 passes the color ramp to the shader using uniforms, this PR passes the color ramp to the shader using textures. This ensures that at least 64 color stops will be supported on all hardware. You can see the difference between these two approaches here.
The elevation stops are packed into an RGBA value using the raster DEM encoding scheme. This means that the minimum distance between stops is set by the quantization of the DEM data (0.1m for
mapboxencoding, 1/256 m forterrarium).Examples:
CHANGELOG.mdunder the## mainsection.