Maya draw overrides RGB color inconsistency issues

Maya draw overrides RGB color inconsistency issues

jwlove
Advocate Advocate
2,440 Views
2 Replies
Message 1 of 3

Maya draw overrides RGB color inconsistency issues

jwlove
Advocate
Advocate

Ok... please bear with me as I try to describe my issue - it needs the background before the question can make sense....

 

I'm creating a gui in PySide2 to set colors for maya curves used as controls in a rig.  Maya has 32 index based colors, and I created a QPushButton for each color (in a 4x8 grid).  I'm also using a QLabel to essentially be a block of color showing which color is currently set.  In order to set the button colors (and the label) to the actual 32 different colors, I needed to use the colorEditor eyedropper to find the RGB values.  Qt uses rgb in a 0-255 scale, which fortunately was just a matter of switching the option in the color picker to use that range (rather than the default 0-1 range).  Unfortunately, when I used the number values I got, the colors did not look right in the gui.

 

After beating my head over the desk, I ended up taking screenshots of each index color in the attribute editor and opened them in photoshop to use the color eyedropper to get the RGB values - and they were DIFFERENT...……  After using those 'new' color values, the gui color buttons matched up and were the 'correct' color - I even tested this by pulling up the color index slider in the attribute editor along with my gui, then opening the colorEditor and using the eyedropper on both the slider color and my gui button - the numbers I got when clicking either were identical within the colorEditor...

 

That's great, and wasn't really a problem (although a tedious and annoying set of steps to take...), but I then decided to make my gui capable of utilizing the override rgb colors as well.  So, now I've got the 32 color buttons, plus another button to open Maya's color picker (using the 'colorEditor' command).  It functions fine as far as setting the right colors on the curves since I'm using either the index values or Maya's native RGB values (they require the 0-1 range), but I can't seem to get my label to have the correct color because of the disparity between Maya's RGB values and the RGB values of Qt (and presumably everything else like photoshop... so, I'm gonna call that a 'standard' RGB).  I also want to take the current color on the label and use that as a starting point when launching the colorEditor with the 'rgbValue' kwarg.

 

To help illustrate the issue, here are 2 of the 32 colors:

- 'light green'

    -color index is 19

    -Maya RGB 0-1 values: (0.056129686534404755, 1.0000240802764893, 0.36625534296035767)

    -Maya RGB 0-255 values: (14 ,255, 93)

    -Qt RGB 0-255 values: (67,  255, 163)

 

- 'pink'

    -color index is 20

    -Maya RGB 0-1 values: (1.0000240802764893, 0.43414777517318726, 0.43414777517318726)

    -Maya RGB 0-255 values: (255, 111, 111)

    -Qt RGB 0-255 values: (255, 176, 176)

 

To get the color on Qt items, I need the 'standard' RGB 0-255 scale.  To get the 'starting color' for the picker, I need a Maya RGB 0-1 scale (setting it on the curves is not an issue because the color editor returns the 0-1 scale values for me to directly set on the curve attributes).  I'm a little unclear on how to convert from 0-255 scale to 0-1 scale in general because if I divide the number by 255, I don't get the same value (ex: 14 / 255 = 0.0549019607843137 which is kinda close to Maya's color picker value of 0.056129686534404755, yet still not the same).  And, I'm extremely confused by the difference in values between Maya and the 'standard' - 14 is about 5.49% of 255, while 67 is about 26.27% of 255... that's a huge disparity.  After some further testing/poking/prodding, there's also a 'Mixing Color Space' in the colorEditor with options of 'Rendering Space' and 'Display Space' which is defaulted to rendering space.  Changing it to display space will update the RGB numbers to match the 'standard' RGB colors (wish I had figured that out before all those screenshots...).  But, it always returns the rendering space values instead of the display space.

 

Ok, so here are my questions...  What kind of RGB conversion is going on here in Maya?  How can I convert 'standard' RGB values into Maya's RGB values (or the display space values to the rendering space)?  How can I go from 0-255 scale to 0-1 scale (and vice versa)?  Preferrably, I need to be able to convert back and forth between Maya's 0-1 RGB values and the 'standard' 0-255 RGB values - if anyone knows the magic equations for each conversion, please share!  If needed, I can also provide the whole list of values for each index (Maya 0-1, Maya 0-255, Qt 0-255).

 

Thanks for any help you can give me!

0 Likes
Accepted solutions (1)
2,441 Views
2 Replies
  • GUI
Replies (2)
Message 2 of 3

jwlove
Advocate
Advocate
Accepted solution

AHA!!!

There's a 'colorManagementConvert' command that will convert the 0-1 Maya RGB values into 'standard' RGB values that I can use for the Qt items!

 

That is exactly what I need to get the maya colorEditor values and generate the correct color for my gui.  It doesn't look like there's a command to go the other way for the sake of the starting color when launching the colorEditor (unless I'm just missing it)… BUT I can work around it by having 2 lists of rgb values for the index colors (one for the gui RGB color values, and one for the corresponding maya RGB color values) and pull from the appropriate list where needed.  If the user has picked a custom RGB color, I can store that value and use it when launching the colorEditor.

 

Huzzah.  (and sorry for posting a question and answering it myself so soon after... Hate when I do that...)

0 Likes
Message 3 of 3

jwlove
Advocate
Advocate

Just an additional note for anyone who comes across this later with the same issue: I did have to multiply each value returned from the 'colorManagementConvert' command by 255 and round that to get the 0-255 range, but that's not  a huge issue...

0 Likes