Hi,
Is there a way to know from a vertex/fragment shader which lights are on or off, and what is the state of OpenGL lighting?
Hi,
Is there a way to know from a vertex/fragment shader which lights are on or off, and what is the state of OpenGL lighting?
I guess you’re looking for those :
struct gl_LightSourceParameters
{
vec4 ambient;
vec4 diffuse;
vec4 specular;
vec4 position;
vec4 halfVector;
vec3 spotDirection;
float spotExponent;
float spotCutoff;
float spotCosCutoff;
float constantAttenuation;
float linearAttenuation;
float quadraticAttenuation;
};
gl_LightSourceParameters gl_LightSource[gl_MaxLights];
Don’t know about the enabled/disabled state of a lightsource, but it shouldn’t be too hard to tell the shader from your app what lights are on.
Originally posted by AdrianPi:
[b]Hi,
Is there a way to know from a vertex/fragment shader which lights are on or off, and what is the state of OpenGL lighting?[/b]
What is the state of OpenGL lighting? Yes.
Which light is enabled? Not directly. You can declare your own:
uniform bool myLightEnable[8];
And then load it with:
int myLightLocation = glGetUniformLocationARB( programObj, "myLightEnable");
glUniform1fvARB( myLightLocation, 8, pFloats );
-mr. bill
Or you can just set the intensity of disabled lights to zero.
Thanks MrBill, but how do I know the lighting state from glsl?
You just said “yes”, but not “how” :eek:
Maybe you didn’t notice the rather large gl_LightSourceParameters struct that PanzerSchreck posted. Or the array of these structures that he also mentioned. Maybe you should take a look at these, seeing as how they encapsulate OpenGL’s lighting state.
Ys I saw that Korval, but I’m talking about the global lighting state, the one we set with glEnable(GL_LIGHTING)
Yes, I saw that, but I’m talking about the global lighting state, the one we set with glEnable(GL_LIGHTING)
Originally posted by AdrianPi:
Yes, I saw that, but I’m talking about the global lighting state, the one we set with glEnable(GL_LIGHTING)
// There *ARE* much *faster* ways to do this!
// For teaching purposes only....
GLfloat Floats[8];
GLfloat *pFloats = &Floats[0];
for (int i=0; i<8; i++)
{
Floats[i] = glIsEnabled( GL_LIGHT0+i );
}
int myLightLocation = glGetUniformLocationARB( programObj, "myLightEnable");
glUniform1fvARB( myLightLocation, 8, pFloats );
-mr. bill
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.