The Dirtchamber
A mixed reality testing environment for real-time global illumination algorithms
|
A common, simple deferred renderer. More...
#include <common_renderer.h>
Public Member Functions | |
virtual void | resize (UINT width, UINT height) |
Resize the deferred_renderer's output to a new width/height . | |
virtual void | update_postprocessing_parameters (ID3D11DeviceContext *context) |
Upload postprocessing paraemters from the postporcessing pipeline. | |
virtual void | update_frame (ID3D11DeviceContext *context, double time, float elapsed_time) |
Update function for everything called once a frame. | |
virtual void | update_camera (ID3D11DeviceContext *context, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
Update function called for the camera. | |
virtual void | reload_shader (ID3D11Device *device, ID3D11DeviceContext *context) |
A function called if the shaders should be reloaded. | |
void | set_shader (ID3D11Device *device, ID3DBlob *input_binary, ID3D11VertexShader *vs_deferred, ID3D11PixelShader *ps_deferred, ID3D11PixelShader *ps_overlay, UINT start_slot, UINT overlay_slot, UINT postprocessing_slot) |
Set deferred rendering shaders. More... | |
virtual void | save (dune::serializer &s) |
Saves dune objects used in the common_renderer. Overload to add more. | |
virtual void | load (ID3D11DeviceContext *context, const dune::serializer &s) |
Load dune objects used in the common_renderer. Overload to add more. | |
Public Member Functions inherited from dune::deferred_renderer | |
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. | |
Protected Member Functions | |
virtual void | do_render_scene (ID3D11DeviceContext *context) |
Derived classes can overload this method to call render() on more dune objects. Buffers etc. are all set up already. | |
void | reset_omrtv (ID3D11DeviceContext *context) |
Resets all render target views to nullptr. | |
void | update_bbox (ID3D11DeviceContext *context, dune::d3d_mesh &mesh) |
Upload the bounding box of a mesh to the pixel shader. | |
void | update_camera_parameters (ID3D11DeviceContext *context) |
Upload camera parameters to the respective shaders. | |
void | update_scene (ID3D11DeviceContext *context, const DirectX::XMMATRIX &world) |
Update the scene with a new model matrix to move/scale/... stuff. | |
void | update_onetime_parameters (ID3D11DeviceContext *context, dune::d3d_mesh &mesh) |
Upload one-time parameters (really just once) such as noise textures. | |
void | render_scene (ID3D11DeviceContext *context, float *clear_color, ID3D11DepthStencilView *dsv) |
Clear the GBufer and render the scene. | |
Protected Member Functions inherited from dune::deferred_renderer | |
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. | |
A common, simple deferred renderer.
Implements a basic deferred renderer with a camera, a skydome, a scene composed from one or more models (gilga_mesh) and a postprocessor with SSAO, Bloom, HDR Rendering, TV grain, Depth of Field, FXAA, Godrays etc.
The common_renderer renders the camera view into a GBuffer with the following layout:
The postprocessor target is a DXGI_FORMAT_R16G16B16A16_FLOAT render_target.
void dc::common_renderer::set_shader | ( | ID3D11Device * | device, |
ID3DBlob * | input_binary, | ||
ID3D11VertexShader * | vs_deferred, | ||
ID3D11PixelShader * | ps_deferred, | ||
ID3D11PixelShader * | ps_overlay, | ||
UINT | start_slot, | ||
UINT | overlay_slot, | ||
UINT | postprocessing_slot | ||
) |
Set deferred rendering shaders.
Sets the complete shaders for a deferred renderer, which includes an input_binary for a fullscreen triangle, a vertex and pixel shader for deferred rendering, an overlay shader which displays GBuffer textures for debugging, a start slot for the deferred GBuffer, a slot for the current GBuffer texture to render on an overlay and a postprocessing start slot where the postprocessor expects the frontbuffer (i.e. the result of the deferred pass) is located at.
device | The Direct3D device. |
input_binary | The input layout for the fullscreen triangle. |
vs_deferred | The vertex shader of the deferred renderer |
ps_deferred | The pixel shader of the deferred renderer |
ps_overlay | A shader which displays an overlay of a selected GBuffer texture for debugging purposes |
start_slot | The slot at which the GBuffer starts |
overlay_slot | A slot at which the currently selected GBuffer texture is located. Call overlay() to render the texture. |
postprocessing_slot | The slot at which the final deferred buffer is located at. |
References dune::postprocessor::set_shader().