I’ve done atmosphere shader that go from blue to orange on sunset, in gamma space its ok, from orange through some pale colors to blue, but in linear its going through som asidish pink and purple to blue.( Any way to fix it?
Use GammaToLinearSpace (from UnityCG.cginc)
Thanks. ) But can you be more specific? Im new to shaders. I pass lerp coef in it?
You can use the helper functions in the cg include to convert values from gamma space to linear space.
float3 gammaSpaceColor = GammaToLinearSpace(linearSpaceColor);
Ideally you should only use linear space but if you are targeting devices that doesn’t support it, you have to make sure your shaders in gamma space look as close to the linear space version as possible. Linear space should be your starting point with gamma space being the fallback for less capable devices.
But the issue is not with my pc cant handle linear color space, I have GTX770, its with the fact that lerping from orange to blue goes through different colors in gamma and linear color spaces in editor. Its like gamma goes upthe swatch through green and linear goes down through red and violet. Will post screenshots when return home.
It is totally expected behavior but linear interpolation of colors doesn’t always do what you expect… Have a look here: http://www.stuartdenman.com/improved-color-blending/
Adding the gamma/linear problem on top doesn’t make it simpler
So there are no easy way to lerp like in gamma? Or this helper function will do what I want? Im a bit confused.
The color space you choose with affect the output and the helper function is, well… just a helper. You should do all your math in linear space and only do the gamma conversion as the final step.
Will try. Thanks.)