Reading the G-Buffer

In this recipe, we will look at the HLSL shader code necessary to read from the G-Buffer's resources. We will then use the screen-aligned quad to implement a debug pixel shader for displaying information from the G-Buffer to screen.

Getting ready

We will follow on from where we left off with Filling the G-Buffer using the same G-Buffer layout as described in that recipe, and make use of the screen-aligned quad from Implementing a screen-aligned quad renderer.

How to do it…

First let's begin by outlining the HLSL code necessary to extract the attributes from the G-Buffer.

  1. We'll start by defining a structure to store the loaded G-Buffer attributes in, as shown in the following HLSL code snippet:
    // Structure for holding loaded G-Buffer ...

Get Direct3D Rendering Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.