I have recently implemented SSAO in my engine(deferred shading), but I am very insecure of how I should combine SSAO with global light and local lights(point light).
Should I do this:
//Global light pass.
vec3 sceneColor = DiffuseBRDF + SpecularBRDF;
float luminance = dot(sceneColor, vec3(0.2126, 0.7152, 0.0722));
sceneColor *= mix(texture(ssaoTexture, texCoord).r, 1.0, luminance);
//Local light pass.
//Use additive blending in this pass, i.e. glBlendFunc(GL_ONE, GL_ONE).
//The final result would be:
vec3 finalColor = sceneColor + pointLight0 + pointLight1 + ... + pointLightN;
or this:
//Global light pass.
vec3 sceneColor = DiffuseBRDF + SpecularBRDF;
//Local light pass.
//Use additive blending in this pass, i.e. glBlendFunc(GL_ONE, GL_ONE).
vec3 finalColor = sceneColor + pointLight0 + pointLight1 + ... + pointLightN;
//Composite pass.
float luminance = dot(finalColor, vec3(0.2126, 0.7152, 0.0722));
finalColor *= mix(texture(ssaoTexture, texCoord).r, 1.0, luminance);