Home Unreal Engine

Neutral Grey Issue

Hey,
been running into a problem recently regarding the neutral grey values of the UDK Material Editor.
From my understanding Constants are set up representing the 0-255 Color Values into a range from 0-1
0 being black
1 being 255 white
0.5 being 128 neutral grey

However, as I've been pushing forward playing around more and more, I've discovered that I haven't understood this system quite yet.

I've loaded an image in with three stripes to present my issue. The topmost stripe is pure black, the middle stripe is a (128,128,128) neutral grey, the bottom one a pure white.
If I subtract a neutral grey from this I expected to get -0.5, 0 and 0.5 out of this. What I've gotten instead was:

LM0BEM7.jpg


The black stripe turned into a value of (-186,-186,-186), the neutral grey stripe into (-144,-144,-144) and the white one into (186,186,186).

Doesn't seem to be a visual display issue on the nodes themselves, as I've tested the outcoming values in various setups. The middle stripe, where it's 0.5 subtracted by 0.5 doesn't effectively turn 0.


Help appreciated. Thanks in advance. :)

Replies

  • lpcstr
    Options
    Offline / Send Message
    You need to realize that when you are working in a photo suite like Photoshop, with RGB values in the range [0, 255], you are actually working with sRGB color values, which are in gamma space. In linear space, neutral grey would be 0.5, and to convert that to gamma space you take 0.5^(1 / 2.2) = ~0.73 * 255 = 186. So 186 is actually your neutral grey, not 128.

    It's important to remember that you need to do all your blending and lighting operations in linear space. The values you return from your shader are expected to be linear, so UDK is expecting you to use a constant value of 0.5 if you want neutral to be displayed. When you import a texture, there is a sRGB checkbox which is checked by default. This means that when the Texture Sample node samples your texture, the pixel value will automatically be converted from gamma to linear for you. So, if you fill a texture with a color (186, 186, 186) and then sample it in your material, you will get a value of (0.5, 0.5, 0.5).

    Generally speaking, you want it to be this way. sRGB encoding dedicates more numerical precision to darker colors, which our eyes are more sensitive to. There may be some cases where your texture doesn't contain data that would benefit from gamma encoding, and in that case you would uncheck the sRGB when importing your texture.
  • wahtye
    Options
    Offline / Send Message
    That clears things up by a lot, thanks!
Sign In or Register to comment.