The Dirtchamber
A mixed reality testing environment for real-time global illumination algorithms
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
dune::deferred_renderer Class Reference

The deferred renderer base class. More...

#include <deferred_renderer.h>

Inheritance diagram for dune::deferred_renderer:
dc::common_renderer dc::rsm_renderer< L > dc::rsm_renderer< dune::differential_directional_light > dc::rsm_renderer< dune::directional_light > drf_renderer gi_renderer

Public Member Functions

void start_capture (ID3D11Device *device, size_t width, size_t height, size_t fps)
 Capture the backbuffer and write it to an MP4 video file. More...
 
void stop_capture ()
 Stop capturing and finalize an MP4 video file.
 
const buffer_collection & buffers ()
 Returns the map containing all buffers indexed by their registers.
 
void add_buffer (gbuffer &buffer, UINT slot)
 Add a gbuffer to the deferred renderer buffer map. More...
 
void add_buffer (texture &target, UINT slot)
 Add a render_target to the buffer map.
 
void set_postprocessor (postprocessor *pp)
 Set a postprocessor to use. If this isn't called or set to nullptr, the deferred renderer output is displayed directly.
 
void show_target (ID3D11DeviceContext *context, const tstring &name)
 Select a render_target by name to display in a small overlay when rendering.
 
virtual void resize (UINT width, UINT height)
 Resize the deferred_renderer's output to a new width/height .
 

Protected Member Functions

void overlay (ID3D11DeviceContext *context, ID3D11RenderTargetView *backbuffer)
 Render a selected target into a small preview window on top of the backbuffer.
 
void deferred (ID3D11DeviceContext *context, ID3D11RenderTargetView *backbuffer)
 Render the deferred pass with an optional postprocessing pass.
 

Private Member Functions

void reassign_everything (ID3D11DeviceContext *context)
 Reassigns all buffers in buffers_ to their respective registers.
 
void clear_assigned (ID3D11DeviceContext *context)
 Clear all registers that have been assigned previously.
 
void blit (ID3D11DeviceContext *context, ID3D11RenderTargetView *backbuffer)
 Render a fullscreen triangle pass.
 
ID3D11ShaderResourceView * target (const tstring &name) const
 Returns a render_target of a given name.
 

Detailed Description

The deferred renderer base class.

This class implements a deferred renderer manager. A deferred_renderer is initialized by "adding" render_target or gbuffer objects to it with given register numbers. These objects are collected into one big buffer map. When rendering, the deferred_renderer will call a deferred shader for a full screen triangle and upload all buffers in the buffer map to their respective registers, which can then be used by the deferred shader.

Next to managing a lot of texture buffers, the deferred renderer can also display a small preview window of a selected buffer (an overlay) and handle a reference to a postprocessor, which augments the output of the deferred shader.

Last but not least the class features a recording function, which will capture the final output of whoever comes last in the pipeline into an MP4.

Member Function Documentation

void dune::deferred_renderer::add_buffer ( gbuffer buffer,
UINT  slot 
)

Add a gbuffer to the deferred renderer buffer map.

A gbuffer of e.g. three render targets starting at slot 4 will upload to register t4, t5 and t6.

Parameters
bufferThe gbuffer object.
slotThe texture register starting number.

References dune::gbuffer::targets().

void dune::deferred_renderer::start_capture ( ID3D11Device *  device,
size_t  width,
size_t  height,
size_t  fps 
)

Capture the backbuffer and write it to an MP4 video file.

Enable capture is a toggle function to either start or stop recording a video of the rendered image using ffmpeg.

Parameters
deviceThe Direct3D device.
widthThe width of the video (doesn't have to be the same as the backbuffers width, but should be power of 2).
heightThe height of the video (doesn't have to be the same as the backbuffers height, but should be power of 2).
fpsThe frames per second written to the video.

Referenced by dc::on_keyboard().


The documentation for this class was generated from the following files: