Hi,
i have a strange issue; i can’t figure out why the value i input displays different to what i’d expect.
I simply multiply texture * color * 2. This should allow me to darken & brighten the image and also should mean that 0.5 or grey is the midpoint where the texture looks un-tinted.
But it doesn’t, at 0.5 it’s darker and i have to input 0.75 to make it look the same visually.
What could be the reason for this, am i overlooking something?
Color space is set to linear, the texture is imported as sprite with DX1 compression, the shader uses Lambert lighting and i’m evaluating it with the sceneview preview lighting.
Changing the color multiplication to be *1 makes it display as expected when the tint color is set to white.
I’m not sure how you are evaluating the final color, but my first guess is that you are overlooking that a Color also has a sRGB/gamma curve applied. The same as on the texture, but you disabled it there if I understand correctly. Sounds about right in terms of the math:
0.75 ^ 2.4 = 0.501
Linear color space might sound like there is no gamma curve, but that’s not really true. Linear means that the gamma curve that is on colors and textures is removed to make things linear before calculations are done. Then the gamma curve is applied again after the calculations, to match the sRGB curve of the display.
Gamma color space does not linearize the values before calculations and simply multiplies them directly. (Which is incorrect, but potentially faster.)
I have to admit i’m not quite grasping what you explained so nicely (the value that i set using the picker is in gamma space, it get’s transformed into linear when passed to the shader and i have to transform it back to gamma to make it look correct later when rendered in linear again?). I found this thread Gamma Space and Linear Space with Shader and using the formula posted in there ( pow(color, 0.454545) ) made it indeed look correct though.
Well, let me explain it like this then. There are many color spaces, but one of them is sRGB, which stands for Standard Red Green Blue. It was modeled after the response curve of CRT monitors, which roughly has an exponent of 2.2. (That 0.454545 is the inverse of that.) The actual sRGB curve is partially linear and partially with an exponent of 2.4. So unless the value is very small, you should calculate with 2.4 and 0.41667.
So, when you send out a signal of 0, the light intensity on screen is 0 and with a signal of 1 it is 1. But when you send a signal of 0.5, the actual light intensity on screen is 0.5 ^ 2.4, which is roughly 0.189. Now, you might ask, why didn’t they just adjust it so a signal of 0.5 leads to an intensity of 0.5? Besides the math involved, that curve actually gets closer to human vision than a straight line would. Which means* that an actual light intensity of 0.189 is a closer match to half intensity of 1 to a human viewer than 0.5 would be.
So, why this history? To let you know that this sRGB curve is embedded deeply into everything. Into every digital image and every screen. If an image has no color profile, a value of 85, 85, 85 (1/3) means a light intensity of 0.0716. So, that color picker that you see on your screen, is actually 7.16 % of full light intensity at 1/3 along the way and 37.8% at 2/3.
Now, as long as you send that signal directly to a screen, it will work as expected. But now lets say that you are adding two light sources that each contribute an intensity of 85 in sRGB space. Easy, 85+85 = 170. Now that’s the gamma way of calculating things. On screen that will actually result in an intensity of 37.8%, which is far from two times 7.16%.
And that’s where the linear workflow comes in. Unity will convert incoming color and texture information into actual light intensities, so you can do correct lighting calculations. This means that with linear workflow a color value of 85 is not an input of 0.333 in the shader, but 0.0716. (And 85+85 = 113.)
(*It also means that you get better use out of the 256 intensities you can represent with 8 bits. If you would store it in a linear way, part of the intensities would have visible gaps in between and others would be indistinguishable to the typical human.)