0
$\begingroup$

A python script inputs RGB values into a Principled BSDF surface node. The system-computed hex equivalent is wrong as is the color.

The color I want is 414c55.

enter image description here

The script passes RGB values 0.254, 0.296 and 0.332 to the node. The node correctly shows those values but the color is wrong:

enter image description here

Switching to the hex tab, we see that the system is showing the wrong hex value for the RGB values I provided.

enter image description here

Here's the node:

enter image description here

MY QUESTION: what do I need to do to get the color I want?

All suggestions are welcome. Thanks in advance!

$\endgroup$
2
  • 1
    $\begingroup$ The hex value is gamma corrected, that's why the value is different. $\endgroup$ Commented Sep 18, 2019 at 7:37
  • $\begingroup$ What's the best strategy to get the color I want, after accounting for the gamma correction? $\endgroup$
    – vndep
    Commented Sep 18, 2019 at 13:54

1 Answer 1

2
$\begingroup$

TL;DR Enter hex values in the hex tab of the color picker.


Hex values in itself don't specify how they are supposed to be displayed. It depends on the color space that is used to interpret the value and the display transform to show it on your monitor. For the internet, where these hex codes are commonly used, it's standard to use the sRGB color space. It uses the Rec. 709 primaries. The conversion of values from CIE XYZ to RGB values includes gamma correction.

If you want to use your gamma corrected sRGB values represented as hex, then you have to use the hex tab to directly enter them. The RGB selection in the color wheel is using scene linear data / scene referred values that are not gamma corrected, which is why you're getting a different color than you're expecting.

In Blender, the Hex and HSV/HSL values are automatically gamma corrected however, for the RGB values, they are in Scene Linear color space, and are therefore not gamma corrected. For more information, see the Color Management and Exposure page.

Hex color selection

Color

$\endgroup$
2
  • 1
    $\begingroup$ In case I'm incorrect with some aspect about color spaces, feel free to correct me. $\endgroup$ Commented Sep 18, 2019 at 10:07
  • $\begingroup$ This worked well. Thanks! $\endgroup$
    – vndep
    Commented Sep 18, 2019 at 22:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .