Implementing a lighting pass for illuminating the scene
The last recipe in the book you how to implement a lighting pass; this is where we calculate the lighting for the scene. For each light in the scene, we draw a volume (for point lights, this would be a sphere; for directional lights, a full-screen quad; for spotlights, we would draw a cone) and for each pixel in that volume, we fetch the data from the G-buffer and calculate the lighting contribution of that light to the pixel. The results are then usually added together (blended) to a final render target to get the final image. In the demo, we only have one spotlight that is used as a demonstration, but we can easily add multiple lights. For each light in the scene, we will need to consider the area affected by the light (i.e., we use a shader that fetches the relevant data for each pixel from the G-buffer, which then uses this data to calculate how much this light source contributes to the final color of each pixel). For example...