Thursday, April 6, 2017

opengl - Deferred shading - how to combine multiple lights?


I'm starting out with GLSL and I've implemented simple deferred shading that outputs G-buffer with positions, normals and albedo.


I've also written a simple point light shader.


Now I draw a sphere for the point light and output goes into a lighting buffer.


The problem is, how do I combine the results of lighting buffer when drawing multiple lights?


E.g. when I'm drawing the second light to the lightbuffer using the point light shader, how do I add first light to the second light in the lighting buffer. I mean, you can't read from and write to the same output buffer?



Answer



Additive blending, i.e. glBlendFunc(GL_ONE, GL_ONE) and glEnable(GL_BLEND).



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...