Color pickers in Viewer and Graph Editor don't handle display space
Both of these editors do not handle conversion to / from display space properly currently.
See the thread found here: https://academysoftwarefdn.slack.com/archives/C0230LWBE2X/p1674221447235719
Seems the fix is to change to use built in conversions in MaterialX to go to / from display space to the space specified for the value.
Would like to work on this issue for ASWF Dev Days 2024!
I'll clear out the assignment on this task, so that it's available for our next Dev Days in May 2025, but feel free to join us then, @sgmq0!
Hey, I'm interested in picking this up for the upcoming Dev Days (May 2025). I will be setting up my MaterialX build today and tomorrow, and will try to familiarize myself with the codebase as much as possible for the 15th. Looking forward to working on this issue!
Also BTW, @sgmq0 and I are actually both in the CG undergrad department at UPenn, and I've confirmed with him that I can take a turn at tackling this.
Welcome @mialana - happy to have you on board for dev days 2025. Please feel free to reach out if you have any questions or problems getting the build setup, either here or on the #materialx ASWF slack channel.
Hello. Are there any more available repositories of example .mtlx Material files, and specifically any that use color4 fields?
To elaborate, for this issue, it is my understanding we also need to add color space transformation in the "Color4" case (please correct me if this is wrong).
I see that there are some node definitions such as ND_UsdUVTexture that have a field <output name="rgba" type="color4" />. However, from what I can tell, none of the example materials in the resources/Materials/ directory of the MaterialX source repo seem to use those nodes.
I'm not familiar if there are any other community-available resources that would be good for testing with? If not, no worries, I can take a stab at creating a Material that uses one of those nodes myself! Just wanted to double-check first...
Regarding example .mtlx files - there are a large number of examples in the resources folder in this repository, a lot of which are actually the basis for our unit tests. If you can't find something you need in there, I'd be happy to help you construct what you need to test with - just ping me on slack - or else you can use the MaterialX GraphEditor itself to create mtlx files interactively too.
Regarding what's necessary here - my understanding of the slack conversation is that we'd like to try and introduce correct color management of the color picker in both (or either) of the MaterialX UI tools (Viewer and GraphEditor). That likely means applying the color transformations that are already defined in the project, to the color value being displayed on the screen, and then (as @kwokcb points out) applying the reverse transformation when the UI edited value is sent back to the MaterialX document.
As @jstone-lucasfilm pointed out in slack - you may find the conversion functions here helpful.
(tagging @kwokcb here incase he may have even more wisdom to share here).
Thanks for the response!
I believe I actually have succssfully implemented the main color space transform logic using the linearToSrgb() and srgbToLinear() conversion functions. I have attached a quick preview of the issue-fix results below.
Currently, I am only unable to test "Color4" inputs with any of the example materials in the repository. Not a problem though, I will go the route you mentioned:
or else you can use the MaterialX GraphEditor itself to create mtlx files interactively too.
I will ping on slack in the future if I run into any issues doing this. Thanks again!
Color3 Blue (Original, no color space transforms applied):
Color3 Blue (Corrected, color space transforms correctly applied):
Color3 Red (Original, no color space transforms applied):
Color3 Red (Corrected, color space transforms correctly applied):
This looks great!
-
The requirement should simply be sRGB display <-> linear conversions so if you're ready a pull request can probably be put up.
-
Here is a simple color4 example:
<?xml version="1.0"?>
<materialx version="1.39">
<constant name="constant_color4" type="color4" xpos="5.652174" ypos="12.387931">
<input name="value" type="color4" value="0.815686, 0.184314, 0.184314, 0.176471" />
</constant>
<convert name="convert_color4_surfaceshader" type="surfaceshader" xpos="8.905797" ypos="12.525862">
<input name="in" type="color4" nodename="constant_color4" />
</convert>
<surfacematerial name="surfacematerial" type="material" xpos="14.630435" ypos="12.422414">
<input name="surfaceshader" type="surfaceshader" nodename="convert_color4_surfaceshader" />
</surfacematerial>
</materialx>
Thanks to @mialana for the Viewer fix in https://github.com/AcademySoftwareFoundation/MaterialX/pull/2394, and let us know if you'd like to address the Graph Editor as well!
Yes I'd like to work on this issue for the Graph Editor as well!
As I mentioned in #2394, I discovered some differences in how ImGUI handles color space. I plan to message ASAP in the MaterialX Slack with a few questions about UI preferences / best practices.
As I was about to send a message in Slack, I took some time to investigate the Graph Editor a bit more. I've submitted PR #2402 with my solution, but feel free to call out anything I may have overlooked. I'm happy to brainstorm on alternative solutions and/or design decisions.
Thanks to @mialana for her impressive work in resolving these issues for Dev Days 2025, with additional thanks to @sgmq0 for getting this work started in Dev Days 2024!