# Blending for multiple lighting passes

I am attempting to perform shadow mapping with deferred shading, using the following code:

for (auto light : m_ShadowDirs)
{
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
//bind depth map
//render
glDisable(GL_BLEND);
}


shadowDirPass(m_ShadowBuffer, light); Simply renders the geometry to the shadow map. m_FrameBuffer.LightingPass(m_ShadowDirLightShader); Just binds the Gbuffer textures.

I have two directional lights in the scene, one with red colour (1,0,0), and one with blue colour (0,0,1)

One would think that the scene would be coloured purple, but no. Every time I render (for each) light, the image in the target framebuffer is overwritten completely, instead of blended together. To illustrate this, see the following images:

Above is the scene with a single red light.

Above is the same scene, with a single blue light, but from a different direction. (See shadows).

When I enable both lights, the result is as if the first light was never used, though by stepping through the code, I can confirm that it is definitely going through a render cycle.

I'm pretty sure than I've messed up the blending somehow, but I could use some guidance.

As it turned out, I was calling glClear(COLOR_BUFFER_BIT), between lighting passes, within the FrameBuffer class. Once I removed that call, it worked fine.