###That structure is not aligned correctly, which may be the source of your problem.
That structure is not aligned correctly, which may be the source of your problem.
To form an array using std140 out of PLight, you need to pad it with an extra float at the end. Otherwise, PLight pLights[TOTAL_LIGHTS] is misaligned and you will fetch the wrong memory from pLights [1] -- everything will be off by 1 scalar component on the second light in this array of structures.
###Consider this instead:
Consider this instead:
struct PLight
{
vec4 pos;
vec4 diff;
vec4 spec;
vec4 amb;
float con;
float lin;
float quad;
float padding;
};
The entire array size needs to be padded out to a multiple of the base-alignment for std140. Your base-alignment in this case is vec4 (4N). So that means to satisfy this alignment you need to add a float to the end. GLSL will do this for you automatically, and this float padding element is something you need to take care of when you declare this structure in code outside of the shader.