Universal Input for Shaders

I have a question about shaders. I’ve noticed that it appears that the automatic shader generator will poll the lights in an environment and apply them to the shader it builds.

During that process it seems like the lights get added in, in their normal place in the fragment shader
Output from the autoshader:

uniform float4 alight_alight0, 
uniform float4x4 dlight_dlight0_rel_view,

But when I try to copy this into a custom shader it breaks down- it says that I have not supplied the lights as input to the shader. Of course, I can just go in and add the setShaderInput line in the script but it would be cleaner if there was a handle on the lights in the scene without having to implicitly input them in the python script.

In other words, where is the voodoo that lets the above code work in the autoshader but fail in a custom shader.

Er, the shader generator supplies extra inputs for the lights, I think. The magic is in the function ShaderGenerator::create_shader_attrib, it does something like this for the lights:

node.setShaderInput("alight0", myAmbientLight)

I figured it was something like that. So the names come from the ShaderGenerator itself and not from the Panda3d environment.

Got it.