2
$\begingroup$

This is a follow-up to an answer to my previous question, Why is this color so different in Texture Paint, and how would I change it?. That question had two parts, as indicated in the title. Both parts were answered by "Mr A". This question is a follow-up to his answer to the first part, Why is this color so different in Texture Paint?

His answer was, "I believe the color picker is using linear space while the texture is using sRGB. If you want the two colors to be consistent, use the Hex value instead. It is gamma corrected." That answer was basically in a foreign language because I didn't know what "linear space," "sRGB," or "gamma" meant in this context. Looking those up led me to a bunch of references that suggested I'll need a second PhD to understand this stuff:

  • Color Management, in Blender 4.0 Manual
  • Four detailed, technical articles on Wikipedia:
    • HSL and HSV
    • sRGB
    • Color space, section Absolute color space
      • This gives one of two definitions of the title term as "A color space in which colors are unambiguous, that is, where the interpretations of colors in the space are colorimetrically defined without reference to external factors." (emphasis added)
    • Gamma correction
  • A long and detailed answer by @troy_s to the Blender StackExchange question, How to get accurate colors with Filmic Blender. (Question edited to add this reference based on comment by @lemon .)
    • States that "without utilizing [the CIE 1931 XYZ model], the values in an RGB triplet are meaningless" (emphasis added)
  • A long and detailed answer by @Myndex to the StackOverflow question, generate colors with the same perceived brightness and saturation, about colors in OpenCV (Open Source Computer Vision).
  • HSL and HSV, en-academic.com
    • This appear to be a pilfered copy of an old version of the Wikipedia article of the same name, linked above. I reference it because it contains a relevant sentence, omitted from the current version of the article on Wikipedia: "Each unique RGB device therefore has unique HSL and HSV spaces to accompany it, and numerical HSL or HSV values describe a different color for each basis RGB space." (emphasis added)

I previously thought that the specification of a color by three numbers for RGB or HSV was unique, i.e., unambiguous, i.e., independently meaningful. The above references tell me that I've been wrong about that. That's the cause of the difference in the colors in my previous question. Now I'm grappling with (a) how to understand the relationship between colors and their RGB or HSV specs, and (b) more importantly, how that relationship affects how I specify colors in different workspaces in Blender.

To try to make sense of this, I went back to the color pickers in my previous question and made pictures of their values in RGB, HSV, and hex:

The light brown color I originally chose in the Layout Workspace:

enter image description here

The dark brown color I got when I copied the HSV values from that into the color picker in the Texture Paint Workspace:

enter image description here

Then I made pictures of the color picker when I entered the hex values obtained in one workspace into the other:

The dark brown color I got when I entered the hex value obtained in the Texture Paint Workspace into the color picker in the Layout Workspace:

enter image description here

And finally, the light brown color I got when I entered the hex value obtained in the Layout Workspace into the color picker in the Texture Paint Workspace:

enter image description here

Then I put the numbers in those pictures into a spreadsheet to look for patterns:

enter image description here

In this spreadsheet, the orange cells in column B are the HSV values for the light brown color that I selected visually in the color picker. The orange values in column C are those original HSV values that I copied into the color picker in Texture Paint. The orange cell in column D is the hex value that I copied from Texture Paint into Layout. And the orange cell in column E is the hex value that I copied from Layout into Texture Paint.

In the bottom part of the spreadsheet, I convert the hex values to the RGB values they represent by splitting them each into three 2-digit hex numbers, converting those numbers to decimal, then dividing by 255. Comparing the results of that to the numbers in the top part of the spreadsheet, I find that the hex value for the light brown in Layout represents the RGB values of the light brown in Texture Paint, while the hex value for the dark brown in Texture Paint represents the RGB values of both the light brown in Layout and the dark brown in Texture Paint. The RGB values for the dark brown in Layout are a third set, not represented by either of the two hex values.

To which I can only say: What???

Or, repeating the questions I asked above:

  • What is the relationship between colors and their RGB or HSV specs in general? And
  • More importantly, how does that relationship affect how I specify colors numerically in different workspaces in Blender?

Shortly before I'm posting this question, a comment has appeared from @GordonBrinkmann on my previous question, in which he says that Andrew, the donut instructor, didn't have the problem I'm having because he chose the colors in both workspaces visually, not numerically. So I suppose Gordon's answer to my second question above is that I should specify my colors visually and not worry about the numbers. I can see that that could work, but I'm a geek who wants to understand the numbers and their relationships.

$\endgroup$
9
  • 1
    $\begingroup$ TL,DR Sorry, color spaces and color models are much too complex topics for a short answer here and not exclusive for Blender (what this site is about). There are tons of websites and Youtube videos on the different color models and how they work and what Linear vs. sRGB means etc. $\endgroup$ Dec 5, 2023 at 9:06
  • 1
    $\begingroup$ Give a try setting the color management to "raw" (default is filmic) and test again. $\endgroup$
    – lemon
    Dec 5, 2023 at 9:34
  • 1
    $\begingroup$ blender.stackexchange.com/questions/92177/… $\endgroup$
    – lemon
    Dec 5, 2023 at 9:37
  • $\begingroup$ @lemon This question is not about how to get correct colors, but 1. "What is the relationship between colors and their RGB or HSV specs in general?" and 2. "how does that relationship affect how I specify colors numerically in different workspaces in Blender?" $\endgroup$ Dec 5, 2023 at 11:04
  • $\begingroup$ @GordonBrinkmann, yes. I think there is something related in parts of the question (brown variations). But I don't know more than that $\endgroup$
    – lemon
    Dec 5, 2023 at 11:09

1 Answer 1

4
$\begingroup$

This is a bit of a messy topic with a bit of history. I will try to explain this in simple terms from memory. This is a disclaimer that I won't be very accurate nor detailed in my answer.

Let's start with linear space. Light as a physical phenomenon behaves linearly. This means that two light bulbs will light a room twice the amount one light bulb would. In other words, 1 + 1 = 2 in linear space. In a nonlinear space, 1 + 1 doesn't equal 2. The values need to be converted to linear space first, do the math, then convert back. Linear space is important for doing light calculations and is, therefore, here to stay.

sRGB is one of many non-linear spaces. In the past, screens, when fed linear colors, would display them incorrectly due to how they functioned. The solution back then was to apply an inverse transformation to the fed colors to make the output linear (look correct for a viewer). This application of non-linear spaces is no longer needed as monitors now are more advanced.

Another application of non-linear spaces is encoding images for storage. If images are stored in non-linear space, more weight can be given to colors the human eye is more perceptive of. This is still relevant till this day, and it is why images are stored in the sRGB space.

Now, you know enough to understand why the color picker for the generated image behaves differently. It is intended to be store as a file in the end.

Before moving on to the next topic, I have to say something. Not all images are intended for the eye, so we don't really need to store them in sRGB space. A metallic texture is normally stored in linear space. Please remember that images are stored in sRGB so that more bits are dedicated for the colors the human eye is more sensitive to, so when the image is converted back to linear for display, it will look like it has higher quality then if it was stored in linear space.

The next topic is conversion between sRGB and linear. There is an approximate way which is done by raising the values to the power of 2.2 (or 1/2.2 if converting the other way). Typically, in Blender, this is done using a gamma node with a gamma value of 2.2. That's where the term Gamma Correction comes from. It means the values are always in sRGB. It seems that this was done to the Hex input to match colors you see in the web. Please note that the conversion using a gamma node is not exact. The exact formulas can be found online. There is a node for converting between color spaces in the Compositor (a screenshot is attached below).

Convert Colorspace

You should now understand why I told you to use the Hex input for the colors. In Blender, this is the way to use the same value to get the same color whether the color picker is used for files or otherwise.

There is another application for non-linear color spaces. This is typically done as a post process effect to rendered images to increase contrast or for other compositing reasons. Standard does nothing (linear) while Filmic is one example of a non-linear transformation.

RGB, HSL, HSV, and Hex are ways of representing colors using numbers. You should be able to convert between them with no issues. However, please be careful with the Hex values in Blender. They are always Gamma Corrected, so they may be in a different space depending on what color field you clicked.

Please don't confuse RGB with sRGB. The former is a way to represent a color while the latter is a color space. An RGB representation can be in linear space, sRGB space, or any other space.

$\endgroup$
1
  • $\begingroup$ we need to create a new color space with a confusing name like "RGB sLinear" just to make this all easier to read. $\endgroup$
    – L0Lock
    Dec 5, 2023 at 20:42

You must log in to answer this question.

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