Thanks for the reply. I hacked at this most the this morning and I'm no closer to a resolution. I've tried it on three different computers. My old laptop running Win 7 and almost GL 3.1, another laptop with Win 8 and GL 4.1 and a desktop with Win 10 and GL4.5. Each is a little different. The second laptop just renders everything black after adding the second light no matter if I use hard coded values, constants, or anything else.
The other two computers seem to render fine when using constants and hacks similar to what was done in the SO link above.
I've tried all different shader versions, but started with 330 and went up from there. Also, my drivers are as up to date as they're going to get. I don't expect anything new for my old laptop.
What I really don't understand is that I'm doing the exact same thing with a regular old uniform and it works:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
struct PointLight
{
vec3 position;
vec3 diffuse;
vec3 specular;
vec3 ambient;
float constant;
float linear;
float quadratic;
};
#define TOTAL_LIGHTS 2
uniform PointLight pointLight[TOTAL_LIGHTS];
vec3 CalculatePoint(PointLight p)
{
...
}
void main()
{
...
vec3 point = vec3(0.0);
for(int i = 0; i < TOTAL_LIGHTS; i++)
point += CalculatePoint(pointLight[i]);
...
}
|
The above code works just fine in the same shader. I can use this method but I wanted to change over to a uniform buffer object so I could access the data easier from multiple shaders. I don't understand why it works one way and not another!
Anyway, I'm going to hack at it a little longer and if it I can't get it to work, I'll revert back to the regular old uniform. Thanks again for your thoughts.