I’m trying to convert my custom shaders from built-in to URP (package version 7.5.1 in 2019.4.9f1) and can’t figure out how to access the ambient color. To clarify, I’m talking about the color set in Lighting > Environment Lighting > Ambient Color when Source is set to Color. I’ve tried the following variables:
…for the last three I also tried setting Source to Gradient, but I can’t get any of those colors in my shader (I’m using return half4(*variable from above*.rgb, 1); in the fragment shader, everything else works fine). They all produce different shades of grey, but not any of the colors I set up in the editor. So how can I get the ambient color?
I always get black when trying BattleAngelAlita’s solution. Light settings are using ambient color. Anything I might be missing that seems obvious but isn’t for this lowly guy?
Edit: I figured out it was just my “Scene Lighting” that was toggled off. It’s working, but I really need to be able to toggle off the Scene Lighting without my custom terrain going black. How do other shaders respect this setting in a way that just ignores the ambient color instead of using the unset values?
Thank you thank you thank you thank you.
That saved my URP Shader. How did you know that would help in Ambient Lighting?
I’ve been digging through documentations without any success.
It is mentioned here: https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html Spherical harmonics coefficients (used by ambient and light probes) are set up for ForwardBase, PrePassFinal and Deferred pass types. They contain 3rd order SH to be evaluated by world space normal (see ShadeSH9 from UnityCG.cginc). The variables are all half4 type, unity_SHAr and similar names.
but I agree with you: the documentation is not so clear!
OMG thank you, this is the only thing that worked for me. The unity_SHAr/g/b were just black. How did you even find it? Manual doesn’t even mention it and it just hangs there in Library/PackageCache/com.unity.render-pipelines.universal@14.0.9/ShaderLibrary/Input.hlsl