-
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
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
Co-authored-by: Jan Nikl <[email protected]>
lib/palettes.cpp
Outdated
{ | ||
if (!first_init) | ||
if ((int)(textures.size()) != Palettes->NumPalettes()) |
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 unfortunately insufficient check, because the number might be the same, but the palettes might be different 💣 . I do not see an easy way how to do this properly, so it is fine for the moment, I guess, but we need to keep this in mind when runtime loading of palettes happens and the driving code will have to call InitTextures()
directly.
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 not used at the moment but you're right. I changed it to a more generic reinitialize
argument that can be used in the future.
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.
That makes sense too 👍 . Maybe let us keep this open for future reference.
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 almost there 😄 Pls, do not forget about that loading above.
Added some changes based on your feedback. Thanks! |
break; | ||
cout << "Warning: palette name <" << palname | ||
<< "> already exists. Overriding..." << endl; | ||
palettes.erase(palettes.begin() + idx); |
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.
As it is a good practice of premature optimization in MFEM, it would be more optimal if you do palettes[idx] = as_unique<Palette>(palname)
😄 . But for unification of the approach it is better like this. Would be better to wrap this call in a method, but also not super important.
Should this be squashed before merging? There is a lot of commits. |
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.
Thanks a lot for this improvement, @justinlaughlin and @najlkin !
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: