Way to check if a light is enabled in shader?

Is there a way to check if a light is enabled in a shader? It would be nice to iterator through all eight lights and deterime at runtime which ones are enabled, rather than the more akward way the Orange book decribes (where the first n lights are used, and n is passed in as a uniform variable). However the specification provides no obvious way to determine a light’s enabled status.

Is there a way to do this?

Mark McKay

What you want to do is generally a bad idea (performance-wise), even on SM3.0 hardware that supports fragment shader branching.

If you absolutely want to try it, you could set the diffuse color of a light to 0.0 to mark it as disabled and test against that in the shader.