I’m trying to use UNITY_LIGHTMODEL_AMBIENT, the ambient light color. It works in Game mode, but in Editor mode, it just returns a gray color always.
Also, a separate issue: even in Game mode, it’s not quite returning the right values, it’s like the color I pick divided by 2.2 or something. If I pick white, it gives me rgb(188,188,188) instead of triple 255.
Well, if you’re in linear, then you’ll get the gamma-corrected version of the light colour; pow(UNITY_LIGHTMODEL_AMBIENT.rgb, gammaValue); (with gammaValue being 2.2 on a PC and 1.8 on a Mac).
And everything in your shader will get converted back to gamma space at the end (via pow(result, 1/gammaValue); ).
Also, I think, by default the built-in shaders and surface shaders multiply it by 2. Essentially, fixed3 ambientLight = s.Albedo * UNITY_LIGHTMODEL_AMBIENT.rgb * 2;
I suspect that it’s being set somewhere in script, though, as it should show up in the editor as well as in game mode. What happens if you make it a really bright green?
I ended up making my own ambient light picker and using Shader.SetGlobalColor. However, I am getting the same gamma related issue. I tried pow(color, 2.2), which is really close, but isn’t quite exactly there. I think it’s close enough for what I need though. Maybe the differences are due to the precision of the 8-bit floats.