2D Deferred Lighting

There generally isn't that much need for deferred lighting in 2D, firstly because your overdraw isn't as big as it sometimes is in 3D, and secondly because your lighting seldomly is as complex as it is in 3D (slimmer vertices so less vertex data to interpolate per fragment, simpler lighting calculations, no SM lookups typically, fewer lights visible in the scene, etc)

So I think you should consider first if it's really worth it. Maybe try implementing what you want to achieve in a forward renderer first, and see what performance is like. Remember that deferred lighting comes with a lot of limitations.

To answer your question, the two main points of DL/DS are 1) to reduce overdraw (every pixel is only shaded once, even if it is drawn many times because of overlapping geometry) and 2) your scene becomes separable with respect to light.

1) should be obvious (but as mentioned is not that big a deal for a 2D game), and for 2), what that basically means is that instead of integrating the rendering equation over all lights in your world/scene like for(current_light_index = 0; i < max_light_uniform; i++){ ... perform lighting math and add to accumulator ... } you can now figure out beforehand for any given pixel what light it is affected by, and then only let the fragment-shader render that pixel with the lights that could affect it. This can be done in several different ways, using multiple passes or for instance splitting up the scene into pieces of geometry. For instance each of your lights could have a spherical radius of influence, so you would split up the screen into a bunch of shapes, and for each piece you then know which lights affect the pixels inside that piece, so you pass the shader the information for those lights. With this you get basically unchanging performance regardless of how many lights you have on-screen, as long as the lights are relatively small, or at least until not too many of the lights overlap and create regions where any given pixel is affected by many many different light-sources.

/r/gamedev Thread