-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Apply color palette on render. #4953
Conversation
Thanks for the pull request @NaderCHASER! Someone should be able to respond to this during our Bug Bash later this week. |
Looks good, thanks @NaderCHASER! Can you please send in a CLA so we can review this? |
"You or any other entity (including a cross-claim or counterclaim in a "lawsuit" is missing the "l". Filling it out and submitting it now. Edit: Completed and sent. |
I have a server-side tiler up and running that can be used. This is the current 2-meter temperature for the US. Min/max must be supplied for the tiler to determine the range to use in the red channel. Here's a sample color palette: http://cache.allisonhouse.com/maps/palettes/TMP_2M.pal Edit: Removed code due to poor formatting. Everything is now in And here is what the rendered image should look like (but doesn't, see post 1): |
I haven't been able to run an example. Can you post a Sandcastle gist? @kring would know where this fits better. I read through the forum posts that you linked. Was the only problem in the second post that vec4 sampleAndBlend(
vec4 previousColor,
sampler2D texture,
#ifdef APPLY_COLOR_PALETTE
sampler2D textureColorPalette,
#endif
vec2 tileTextureCoordinates,
vec4 textureCoordinateRectangle,
vec4 textureCoordinateTranslationAndScale,
float textureAlpha,
float textureBrightness,
float textureContrast,
float textureHue,
float textureSaturation,
float textureOneOverGamma,
float split)
{
//... and rearranging the call in GlobeSurfaceShaderSet.js. |
@bagnell I haven't tried the I'm working on a sandcastle and the suggested change now. Will update in an hour or so once I've completed them. |
I've committed a fix for an accidental code removal (frustumSplits[] in FrameState.js). I've also comitted a sandcastle. The problem is that I can't test the sandcastle myself due to a CORS issue. I'll be doing some server-side stuff to get a public URL which has "Access-Control-Allow-Origin: *" |
* Removes unique sampleBlendAndPalette() function which was mostly duplicated. * Adds a second boolean argument to tell the function whether or not to palette the imagery.
Source/Shaders/GlobeFS.glsl
Outdated
@@ -38,6 +38,10 @@ uniform float u_dayTextureOneOverGamma[TEXTURE_UNITS]; | |||
uniform vec4 u_dayTextureTexCoordsRectangle[TEXTURE_UNITS]; | |||
#endif | |||
|
|||
#ifdef APPLY_COLOR_PALETTE | |||
uniform sampler2D u_dayTextureColorPalette[TEXTURE_UNITS]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is causing the WebGL warnings. There aren't as many color palettes as there are TEXTURE_UNITS
. Define another constant for the number of color palettes and use that as the size of the array.
@@ -67,6 +71,7 @@ varying vec3 v_mieColor; | |||
vec4 sampleAndBlend( | |||
vec4 previousColor, | |||
sampler2D texture, | |||
sampler2D textureColorPalette, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you don't have the same number of color palettes, create a uniform of indices into u_dayTextureColorPalette
for each texture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you can pass the index directly here
Source/Shaders/GlobeFS.glsl
Outdated
@@ -110,6 +116,25 @@ vec4 sampleAndBlend( | |||
} | |||
#endif | |||
|
|||
if(applyTextureColorPalette > 0.0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the index is a valid value, say >=0
execute this code.
a1 = mix(tA, tB, f.y); | ||
} | ||
|
||
vec4 pixColor = texture2D(textureColorPalette, vec2(0.0, a1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Index directly into u_dayTextureColorPalette
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using u_dayTextureColorPalette[index] here results in
'[]' : Index expression must be constant
error. * Creates a `PALETTE_UNITS` constant to fix `bindTexture` errors. * Passes a boolean to sampleAndBlend to tell it whether or not to palette the dayTexture.
I've pushed up a change which is an adaptation of your recommendation. I don't believe I can pass the index as an argument in GLSL because the array is of an unknown length at compile time. Correct me if I'm wrong here, but I just couldn't ever get that to work. I did, however, create a Edit: Add |
Code has been updated to pass all checks. Issue list is in the top post. Biggest current issues are a) removing the "paletted" layer causes the underlying imagery to be paletted at the top edge and b) zooming in/out can lead to a strip of tiles not being paletted. |
Thanks for all the updates, @NaderCHASER! @bagnell when you have the chance, perhaps after #4979 and the orthographic projection, can you do another review here? |
Congratulations on closing the issue! I found these Cesium forum links in the comments above: https://groups.google.com/forum/#!msg/cesium-dev/CE_91W9dPUA/g9DrqgPJBAAJ If this issue affects any of these threads, please post a comment like the following:
I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
This PR needs help and I know it. I've been posting on the forum but have yet to receive any real response from Ceisum graphics programmers.
Here's a task list:
Palette weirdness on zooming (see attachments)Determined to be a data issue. Fixed URL at c00a7b4ImageryLayer.js
) and assigned to the proper variable (should it be private/separate from the option?)min
/max
, addpickFeatures
capabilities to display the value at a particular point. (Should it useImageryLayer._imageryCache
?)https://groups.google.com/forum/#!msg/cesium-dev/CE_91W9dPUA/g9DrqgPJBAAJ
https://groups.google.com/forum/#!topic/cesium-dev/J3ws_ikULrk
https://groups.google.com/forum/#!searchin/cesium-dev/Custom$20image$20filters$20in$20SingleTileImageryProvider%7Csort:relevance/cesium-dev/aysBQWn9c88/JoR0dpQ_DAAJ
NASA JPL's use-case for this: