Bug in MonoGame effect parameters (Elements)?

I have an effect with the following lights data:

// lights
float3 LightColor[MAX_LIGHTS_COUNT];
float3 LightPosition[MAX_LIGHTS_COUNT];
float LightIntensity[MAX_LIGHTS_COUNT];
float LightRange[MAX_LIGHTS_COUNT];
float LightSpecular[MAX_LIGHTS_COUNT];

I set the first light’s params like this:


I even validate it later via debug by doing GetValue(), and value is OK.

However, no matter what I do it seems like the shader is permanently stuck with the first value I ever set! If I change position and even do GetValue() to validate it, the shader itself still behaves like the first position I put is the position it knows. I validated this by outputting position as color.

The only way to change the value, once set, is to close the program and run it again. Via multiple runs I could validate that my shader works fine, but its just the SetValue() not working, like MonoGame has some internal cache and it doesn’t really load the new data to the shader.

Anyone knows what the heck is going on? Can anyone confirm that setting elements really work?


Yes, this is a bug. You can use SetData on the parameter instead of the individual elements as a workaround.

1 Like

Yeah I already switched to SetData on the entire array… Thanks for the tip.