Deferred rendering
Deferred rendering/shading is a technique that gives us greater control over how certain effects are applied to a scene by not enabling them during the first pass. Instead, the scene can be rendered to an off screen buffer, along with other buffers that hold other material types of the same image, and then drawn on the screen in a later pass, after the effects have been applied, potentially in multiple passes as well. Using this approach allows us to separate and compartmentalize certain logic that would otherwise be entangled with our main rendering code. It also gives us an opportunity to apply as many effects to the final image as we want. Let's see what it takes to implement this technique.
Modifying the renderer
In order to support all the fancy new techniques we're about to utilize, we need to make some changes to our renderer. It should be able to keep a buffer texture and render to it in multiple passes in order to create the lighting we're looking for:
class Renderer...