I'm not yet happy with the way ambient lighting is done at the moment, especially when you want to apply more complex methods like using ambient cube maps.
Currently the standard way is making a DrawGeometry pipeline call with a special context, e.g. "AMBIENT". The problem is that the materials of each object need to include the ambient cube map. This makes it hard to change the lighting by replacing the cubemap since all the materials would have to be updated.
One idea to solve this is using a light source as ambient light. The light source could have a material which defines the ambient cube map and just gets a fov of 360 degrees and a very large radius. This could work in some cases.
It would work when you have some sort of early z pass in the pipeline that writes to the depth buffer. So the ambient light is simply additive and treated as all other light sources. But if you don't want to use this z pass you have a problem. The ambient light should not use any blending (since the framebuffer is still empty). You can specify the blend mode in the shader but the problem is that it is not guaranteed that the ambient light source is drawn before other light sources which could lead to wrong results.
My proposal to solve this dilemma is to add a new flag "DrawFirst" to the light nodes. Lights with this flag are rendered before any other lights and consequently the first render pass is not an additive one.
If anyone has a better idea or any comments please post them!