Fix overwriting of alpha values in Viewer colorpicker#2404
Merged
jstone-lucasfilm merged 6 commits intoMay 23, 2025
Merged
Conversation
mialana
commented
May 21, 2025
| // Transform sRGBA color picker value to linear space for writing to material | ||
| mx::Color3 linearCol = mx::Color3(c.r(), c.g(), c.b()).srgbToLinear(); | ||
| mx::Vector3 v(linearCol[0], linearCol[1], linearCol[2]); | ||
| mx::Vector4 v(linearCol[0], linearCol[1], linearCol[2], c.a()); |
Contributor
Author
There was a problem hiding this comment.
Additionally, I realized that in my previous PR to handle color space transformations, I erroneously concatenated all 4D color vectors to 3D when writing to material. This is my mistake, and is fixed in this PR.
jstone-lucasfilm
approved these changes
May 23, 2025
jstone-lucasfilm
left a comment
Member
There was a problem hiding this comment.
Thanks for these fixes, @mialana!
There's one minor coding style issue in the change, but I'll just make the adjustment on my side before merging.
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
667d309
into
AcademySoftwareFoundation:main
32 checks passed
Contributor
Author
|
Thank you @jstone-lucasfilm for making the changes on your end -- sorry I missed these notes yesterday! |
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.
Currently, if an user uses the MaterialXView colorpicker for a
Color4field, the alpha component is automatically overwritten and transformed to a value of 1, regardless of original value. Although it is shown unmodified in the UI, if written out to file, the alpha component is always "1". e.g.This is because the Nanogui
ColorWheelclass does not handle color values with 4 components, yet the NanoguiColorPickerclass refers to its color wheel member to set the new picked color (code ref).To prevent this from happening, I modified the current
class EditorColorPicker : public ng::ColorPicker, and created custom callbacks form_color_wheelandm_pick_button. The logic essentially is -- since we have additional color widget members in our color picker, we instead refer to their values when setting the color value. Then, the alpha component can only be changed via the color widgets, so interacting with the color wheel does not change / overwrite the original alpha component.The following GIF is a simple visual demonstration of the alpha being correctly preserved and previewed in the
PickButton. I've also tested saving out to file to validate the written value.