Original Post
Greetings, While implementing per-pixel lighting in GLSL, I attempted to use the built-in gl_LightSource array instead of creating and setting uniform variables for the light properties. I kept getting black results, and I narrowed it down to this: gl_LightSource[0] fields are all zeroed. I'm 100% positive I'm setting the lights and enabling them--fact is, while gl_LightSource[0].diffuse is all zeros, gl_FrontLightProduct[0].diffuse is the correct (non-zero) value (multiplied by material diffuse, which is (1,1,1,1)). I'm running on this on an X300, with the only available ATi driver for Vista x64. I reproduced the same results with TyphoonLabs "Shader Designer". The stripped-down shaders: So: 1. Is this a driver bug, or I'm missing something? Is support for gl_LightSource optional or mandatory for GL 2.0+ drivers?1 2. Anyone ran into this before? Is it a known issue? Any known workarounds? (other than using uniform variables and setting them, obviously [smile]) [1] Pardon the noobiness. I'm used to the Direct3D approach, and have only plunged into GLSL the day before yesterday
// Vertex
void main()
{
gl_Position = ftransform();
gl_FrontColor = gl_Color;
}
// Fragment
void main()
{
// The following line always produces black. I tried using many fields
// including position, specular, etc, and all are zero
vec3 diffuse = gl_LightSource[0].diffuse.rgb;
// The following (commented) line produces the expected diffuse color
// vec3 diffuse = gl_FrontLightProduct[0].diffuse.rgb;
gl_FragColor.rgb = diffuse;
gl_FragColor.a = 1.0;
}