-
Notifications
You must be signed in to change notification settings - Fork 53
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
Color palettes #289
base: master
Are you sure you want to change the base?
Color palettes #289
Conversation
It looks like tests 15 and 17 are failing because they cycle color palettes backwards using |
This seems like going a bit overboard with the palettes. 😁 The size of |
I started with just a few, but it was taking a while so I wrote a script to help, and then I figured might as well add most 😆. I think we had 43 before and this adds 28? Could pare it down too... |
Some suggestions from gm:
Extra colormaps + user defined ones would still be accessed through F6? |
To clarify
The idea will be to have an optional colormap file (could be configurable at build time, or just "colormaps.dat" in the same directory as the executable) and for This way, we preserve the default behavior, while allowing for local customization. |
@justinlaughlin, I think it will be still cool to add an optional input file for this. Happy to chat if you want to give it a try. |
…? BasePalettes holds pre-compiled palettes
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.
I have a point for discussion here. Alpha channel is now supported by palettes technically, but except two special external palettes there is no way how to use this feature. So how about adding some option to add alpha channel to existing palettes? For example, there could be an extra option after pressing F6, which would add a simple gradient from 0 to 1 to your selected palette and you could optionally set the repetition/reversion in a similar way to the (non-alpha) color palette? 🤔 That would work nicely in most cases without the need to have special palettes for that 😉 . |
I like your suggestion - but I think it would make more sense as an extension of the existing "global" alpha modifier (ie the modifier changed byk, K, ,, <) rather than the palette alpha channel itself. Palette repetition/reversion is already a global state (represented in IMO the main use for custom alpha maps is to highlight certain parts of the data (kind of like more customizable level sets), especially when there is lots of occlusion eg in volumetric rendering. The NVIDIA IndeX plugin has some nice examples. But, in order to do that you need a more sophisticated alpha editor (paraview lets you define it as a piecewise linear function). I think what you want to highlight is often pretty specific to the data/palette. TBH I think the global modifier is already good as-is; it could get kind of complicated if we add too many features (what if you reverse the palette, but don't want the alpha channel reversed too?). I think some useful directions for the future may be 1) more formats to load from (paraview exports palettes as a |
Sure, some easier ways how to define palettes would be nice and may include that alphas 😉 . But I was thinking of something basic at the level of the default palettes, where you also cannot specify any levels you want highlight, but still most of the people are fine with that. Most of the palettes are linear, highlighting one end of the scale, so that would match the 0 to 1 gradient, or they have uniformly distributed levels, which can be achieved by repetition of the alpha gradient. |
I added the cet maps For VisIT maybe in a future PR we should add a loader for their I'd need to dig a bit more on matplotlib's license (they say it is a mixture of the licenses of each contributor?); they do have a nice list of externally maintained colormaps that maybe we can consider adding from in the future? |
We could also use the check
Now that I think about it more, I'd prefer a less context dependent solution. What if a user uploads a palette with no alpha but wants to add a linear mask? I think the issue is that F6 already asks for a lot of information at once as is; I'd personally prefer if we implemented something like #287 first, and then add this alpha adjustment idea as a command. I suggest we separate this into a different PR. Many GLVis commands are already kind of confusing (IMO 🫣) and I think this would add more confusion. E.g. k, K sets one kind of alpha mask (I assumed it was uniform, but once I read the source I realized its a two-sided exponential curve (see plot); with a peak shifted by , and <). If F6 is (sometimes) used to set a linear mask (and another key else for uniform? something else for piecewise linear?) that is too many different keys + context to keep track of. |
Wow 😳 , I ...and probably all other users 😄 ... did not know it is complicated like that 🙃 . But when you look at that, it is actually close to what I was proposing with the linear gradient. So definitely I would not add another layer of logic to the alpha channel, but it is another reason to implement the logic in palettes to unify the whole thing. Also incorporating the settings to the |
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.
Almost there 👍
lib/palettes.cpp
Outdated
GLuint alphaTexId; | ||
|
||
glGenTextures(Num_RGB_Palettes * 2, &(paletteTexIds[0][0])); | ||
glGenTextures(Palettes->NumPalettes() * 2, &(paletteTexIds[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.
I thought this will go to Texture
, i.e., it will hold the actual OpenGL texture 🤔 . It would also save some memory, because texture_data
are needed only temporarily to prepare the textures 😉 .
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.
I also had this in mind but was holding off to wrap this up 😅.. but I agree with you that it would be cleaner. I'll make this change - some other things like global alpha texture (from PaletteState::GenerateAlphaTexture
) will also need to be refactored similarly.
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.
See 4d4be89
Co-authored-by: Jan Nikl <[email protected]>
Co-authored-by: Jan Nikl <[email protected]>
Co-authored-by: Jan Nikl <[email protected]>
Refactor Palettes for better customization
This PR:
lib/base_palettes.cpp
and exported asBasePalettes
. Some of these were generated by functions and are now just defined explicitly.-p <palette_filename>
; an example palette file with the proper structure is undershare/palettes.txt
(this includes all of the palettes mentioned in the old version of the PR).RGBAf
(to represent RGBA in [0,1] float format)Palette
(holdsvector<RGBAf> colors
andstring name
)PaletteRegistry
(holdsvector<shared_ptr<Palette>>
)PaletteState
; previously it required the global variablesNum_RGB_Palettes
,RGB_Palette_Sizes
,RGB_Palettes
, andRGB_Palette_Names
. Now it uses a pointer to aPaletteRegistry
. By default, aPaletteState
will be initialized with the global variableBasePalettes
but it is not necessary.Misc notes:
PaletteState::GenerateAlphaTexture
.BasePalettes
is updated before anyPaletteState
are created, they initialize properly, but because textures are created byPaletteState::Init
this could lead to problems if palettes are loaded in at a later point in the run. Moving the functionality toPalette
, egPalette::as_texture()
with caching could be a solution. (there are several other methods that should be moved toPalette
so thatPaletteState
is just in charge of the state).Original PR
There is a nice resource from Fabio Crameri that provides a lot of color-vision deficiency friendly and perceptually-uniform color maps [see issue 268, and reference]. This PR adds most of those colormaps into GLVis.
Here is an example of
batlow
I wrote a small script to help munge the colormap files into something copy-pasteable. I'm not sure if it's worth adding to the repo but I posted it as a gist. The colormaps added in this PR are listed in the gist: