Qt 5.7 | Qt 3D | Qt 3D: Deferred Renderer C++ Example

Qt 5.7.1 Reference Documentation

# Qt 3D: Deferred Renderer C++ Example

Deferred Renderer demonstrates using a two pass rendering method. First, all the meshes in the scene are drawn using the same shader that will output the following values for each fragment: world normal vector, color, depth, and world position vector.

Each of these values will be stored in a texture, which together form what is called the G-buffer. Nothing is drawn onscreen during the first pass, but rather drawn into the G-buffer ready for later use.

Once all the meshes have been drawn, the G-buffer is filled with all the meshes that can currently be seen by the camera. The second render pass is then used to render the scene to the back buffer with the final color shading by reading the values from the G-buffer textures and outputting a color onto a full screen quad.

For more information, see Deferred Renderer.

## Running the Example

To run the example from Qt Creator, open the Welcome mode and select the example from Examples. For more information, visit Building and Running an Example.

Files:

- deferred-renderer-cpp/final_gl2.vert
- deferred-renderer-cpp/final_gl3.vert
- deferred-renderer-cpp/finaleffect.cpp
- deferred-renderer-cpp/finaleffect.h
- deferred-renderer-cpp/gbuffer.cpp
- deferred-renderer-cpp/gbuffer.h
- deferred-renderer-cpp/geometry_gl2.vert
- deferred-renderer-cpp/geometry_gl3.vert
- deferred-renderer-cpp/pointlightblock.cpp
- deferred-renderer-cpp/pointlightblock.h
- deferred-renderer-cpp/sceneeffect.cpp
- deferred-renderer-cpp/sceneeffect.h
- deferred-renderer-cpp/deferred-renderer-cpp.pro
- deferred-renderer-cpp/deferred-renderer-cpp.qrc