Custom lighting model and magic variables

I’m wondering where does the variables _SpecColor and _LightColor0 come from? It is used in the built in lighting models but I don’t understand how they are set. I’m trying to write a custom lighting model but the _SpecColor is pure black. Where do their values come from?

The default values of lights are defined in unitycg.cginc and in Lighting.cginc, and passed to the shaders by the engine during runtime, probably in a similar way as using the static SetGlobal-methods for vectors, colors and matrices etc. documented here.

See this article on Smooth Specular Highlights, and notice in particular the comments inside the shader code, which addresses these variables. _SpecColor is the only one which differs, as it doesn’t come from the cg-includes, but is user specified for each material (since each material can have its own color for specular highlights).

If you want to see the source of the includes yourself, they’re located inside your Unity install directory. The default path is C:/Program Files/Unity/Editor/Data/CGIncludes. (Using forward slashes in the path because Unity Answers eats my backslashes…)