float4 var = float4( , , , has uninitialized component SunLit);
Basically sunlit is null as far as the error goes.
.
.
If the variable sunlit is a floating constant defined in the shader you could declare it static. However that is only good for testing because gl or dx will not allow that and ignore it (i forget which one).
So instead declare it in the shader …
float SunLit;
Then from game1 after you load the effect initialize the variable …
myEffect.Parameters["SunLit"].SetValue(0.0f);
. you should probably do it that way for all those values that are acting as if defaults because currently on the shader default values as a rule of thumb are unreliable and a easy way to cause yourself a bug that is really hard to find.
Also when debuging stuff like this in your shaders in the future if its really annoying. Separate out the values like so.
float4 myvar = float4(1f,1f,1f,1f);
myvar.x = SpecularIntensity;
myvar.y = Shininess;
myvar.z = MoonLit;
myvar.w = SunLit; // you should get a error here now.
// or on each line that has a unitialized value in the vs console window which tells you what line the error is on.
SunLit and MoonLit are both defined in the shader and are both setup in C#
I added SunLit last week and came up with a way of calculating when an object passes into the Earths shadow and is no longer lit by the sun. It worked perfectly in both my forward renderer and deferred renderer.
So I decided to add MoonLit to the deferred renderer.
Which is when this annoying bug came up.
The key point is that I can use either one of MoonLit or SunLit and it compiles, but if I use both it does not.