# incorrect gradient in linear color ramp

I would like to use linear color ramp in blender. But in the middle of it is not 50% grey, but strange value 0.735357. This is incorrect. Why?

• – J...
Sep 30, 2019 at 18:54

The value is linear:

Human vision is not linear. Preceived value of a diffuse surface reflecting 50% of light looks brighter than middle grey to us. Humans preceive around 21% or 18% reflected light as middle grey depending on who you ask. The Value in HSV is based on preception.

If you used Gamma node with 2.2 after the gradient it would output approximately linear greadient based on human preception.

TL;DR The values for HSV are correct. The reason for the deviation is that HSV values have been gamma corrected unlike the RGB values which are scene linear.

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.

Given the scene linear RGB values $$(0.5, 0.5, 0.5)$$ we can convert them to a color space, apply the gamma correction and then convert the values to HSV. The formula for the gamma correction depends on the color space that the values a transferred into. When the default settings are used that would be sRGB which is consistent with the result you're getting. The equation for the gamma correction specified by IEC 61966-2-1:1999 is:

$$\gamma_{sRGB}(x) = \begin{cases} 12.92x,& x \le 0.0031308\\ 1.055 x^{\left(\frac{1}{2.4}\right)} -0.055 , & \text{otherwise} \end{cases}$$

For the given values this results in $$1.055 \times 0.5^{\left(\frac{1}{2.4}\right)} - 0.055 = 0.735357$$ for each color. Therefore the intermediate result is $$(0.735357, 0.735357, 0.735357)$$.

$$MAX = max(R, G, B)$$ $$MIN = min(R, G, B)$$

$$H(R,G,B) = \begin{cases} 0, & MAX=MIN,& R=B=G\\ 60° \times \left(\frac{G-B}{MAX-MIN}\right), & MAX=R\\ 60° \times \left(2 + \frac{B-R}{MAX-MIN}\right), & MAX=G\\ 60° \times \left(4 + \frac{R-G}{MAX-MIN}\right), & MAX=B\end{cases}$$

$$S(R,G,B) = \begin{cases}0, &MAX=0,& R=G=B=0\\ \frac{MAX-MIN}{MAX}, &otherwise\end{cases}$$

$$V(R,G,B) = MAX$$

Since $$R,G,B$$ all have the same value $$MAX=0.735357$$ and $$MIN=0.735357$$ which results in $$H = 0$$, $$S = 0$$ and $$V = 0.735357$$.

In conclusion the HSV value of $$(0.0, 0.0, 0.735357)$$ is the correct result.

This is most likely due to something going on internally with the gamma, color management, RGB values, etc... This is a VAST topic, you can look it up online, personnaly it makes my head hurt, but my guess would be that this is not a bug or anything like that, just the way Blender manage colors and values.

This post kind of hint at these things : https://blenderartists.org/t/colors-in-blenders-rgb-do-not-display-correct-rgb-values/634815/7

And I found this comment on reddit which would be my guess for your problem:

Welcome to gamma correction! 50% gray as it appears on your monitor and 50% gray as renderers understand it are sadly not the same thing. This PDF will explain a little further: http://www.pixsim.co.uk/downloads/The_Beginners_Explanation_of_Gamma_Correction_and_Linear_Workflow.pdf

But basically, the HSV tab (and the hex code) are shown in display space, but the actual color values (and thus the RGB tab) are linear. Thus setting V=0.5 or #7f7f7f gives RGB=.212 (rounding aside). Blender does a pretty good job of making linear workflow "just work" out of the box, so usually you don't need to worry about this.

If you're in Photoshop, everything you see is in display space, so just set to to 50% gray (however it displays it) and make sure Blender/Cycles loads it as a color data. It will take care of transforming it back to .21, which was the actual value you wanted.

Yes, Linear is correct, but only for RGB, not for HSV. Option "Linear" does not exists for HSV. - When you switch color space from RGB to HSV, "Linear" automatically switches to "Near"

Thanks to both for good answers.