what is the meaning of each component of this variable?
That’s one question with hard-to-find answer. The only information I could dig up(it’s so old it’s not funny and no docs at all):
https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Multiple_Lights
This quote is old, but might help(unfortunately, links are long dead).
http://forum.unity3d.com/threads/cg-shader-light-color.151535/
Also, I’ve seen that attenuation used to compute like that (in several shaders):
I’ve never seen it used in any other form in any shaders I could find.
It’s listed in UnityShaderVariables.cginc:
// x = cos(spotAngle/2) or -1 for non-spot
// y = 1/cos(spotAngle/4) or 1 for non-spot
// z = quadratic attenuation
// w = range*range
half4 unity_LightAtten[8];
It does not appear that .w is used in any code anymore, likely because they clamp the light range using a stencil mask now.
thx
thx…got it