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

A Light Propagation Volume. More...

#include <light_propagation_volume.h>

Inheritance diagram for dune::light_propagation_volume:
dune::shader_resource dune::delta_light_propagation_volume

Public Member Functions

virtual void destroy ()
 Destroy the shader_resource and free all memory.
 
void set_inject_shader (ID3D11VertexShader *vs, ID3D11GeometryShader *gs, ID3D11PixelShader *ps, ID3D11PixelShader *ps_normalize, UINT inject_rsm_start_slot)
 Set the complete injection shader. More...
 
void set_propagate_shader (ID3D11Device *device, ID3D11VertexShader *vs, ID3D11GeometryShader *gs, ID3D11PixelShader *ps, ID3DBlob *input_binary, UINT propagate_start_slot)
 Set the complete propagation shader. More...
 
virtual void inject (ID3D11DeviceContext *context, gbuffer &rsm, bool clear)
 Inject VPLs from an RSM into the LPV. More...
 
void render (ID3D11DeviceContext *context)
 Run the normalization and propagation of the LPV.
 
void visualize (ID3D11DeviceContext *context, d3d_mesh *node, UINT debug_info_slot)
 A rendering function to visualize the LPV with colored cubes for each voxel.
 
virtual void to_ps (ID3D11DeviceContext *context, UINT slot)
 Upload the shader resource to register slot of a pixel shader.
 
cb_gi_parametersparameters ()
 Return local cbuffer parameters.
 
const cb_gi_parametersparameters () const
 Return local cbuffer parameters.
 
size_t num_propagations () const
 Get/set the number of propagation steps for the LPV.
 
void set_num_propagations (size_t n)
 Get/set the number of propagation steps for the LPV.
 
void set_model_matrix (ID3D11DeviceContext *context, const DirectX::XMFLOAT4X4 &model, const DirectX::XMFLOAT3 &lpv_min, const DirectX::XMFLOAT3 &lpv_max, UINT lpv_parameters_slot)
 Set/get the world -> LPV matrix, which transforms world coordinates to LPV volume coordinates.
 
const DirectX::XMFLOAT4X4 & world_to_lpv () const
 Set/get the world -> LPV matrix, which transforms world coordinates to LPV volume coordinates.
 
- Public Member Functions inherited from dune::shader_resource
virtual void to_vs (ID3D11DeviceContext *context, UINT slot)
 Upload the shader resource to register slot of a vertex shader.
 
virtual void to_gs (ID3D11DeviceContext *context, UINT slot)
 Upload the shader resource to register slot of a geometry shader.
 
virtual void to_cs (ID3D11DeviceContext *context, UINT slot)
 Upload the shader resource to register slot of a compute shader.
 

Detailed Description

A Light Propagation Volume.

This class manages all resources and rendering steps necessary to create a Light Propagation Volume (LPV). This includes a variety of shaders and several volume textures, as well as constant buffers to transform from world to volume space etc.

Member Function Documentation

void dune::light_propagation_volume::inject ( ID3D11DeviceContext *  context,
gbuffer rsm,
bool  clear 
)
virtual

Inject VPLs from an RSM into the LPV.

Injects VPLs generated from the parameter rsm into the LPV. The exact method to generate VPLs is implementation-dependend, but the behaviour can be overwritten.

Parameters
contextA Direc3D context.
rsmA reflective shadow map with colors, normals and lineardepth.
clearIf true, the volume will be cleared before injection.

References dune::profile_query::begin(), dune::clear_rtvs(), dune::profile_query::result(), dune::set_viewport(), dune::sampler_state::to_vs(), and dune::gbuffer::to_vs().

void dune::light_propagation_volume::set_inject_shader ( ID3D11VertexShader *  vs,
ID3D11GeometryShader *  gs,
ID3D11PixelShader *  ps,
ID3D11PixelShader *  ps_normalize,
UINT  inject_rsm_start_slot 
)

Set the complete injection shader.

Set the injection shader for the LPV, which includes vertex, geometry and pixel shader, as well as a normalization pixel shader. The injection reads VPLs from a gbuffer bound to texture slots starting at inject_rsm_start_slot, and after the injection normalizes it (i.e. divides each voxel by the number of injects it received).

Parameters
vsThe injection vertex shader.
gsThe injection geometry shader.
psThe injection pixel shader.
ps_normalizeThe normalization pixel shader.
inject_rsm_start_slotThe slot at which all gbuffer textures will be bound consecutively.

References dune::exchange().

void dune::light_propagation_volume::set_propagate_shader ( ID3D11Device *  device,
ID3D11VertexShader *  vs,
ID3D11GeometryShader *  gs,
ID3D11PixelShader *  ps,
ID3DBlob *  input_binary,
UINT  propagate_start_slot 
)

Set the complete propagation shader.

Set the propagation shader for the LPV, which includes vertex, geometry and pixel shader, a binary input layout and a starting slot for the volumes which are currently read from.

The propagation works by switching between a front and backbuffer volume for the LPV. In each step, the previously rendered volume is bound as input and read from to propagate energy and write it to a new volume. The three volumes for red, green and blue spherical harmonic components are bound to inject_rsm_start_slot consecutively. Since the geometry shader is in charge of scattering radiance to neighbor voxels, it also needs an input layout for some basic vertices.

Parameters
deviceThe Direct3d device.
vsThe propagation vertex shader.
gsThe propagation geometry shader.
psThe propagation pixel shader.
input_binaryA blob of the shaders input layout.
propagate_start_slotThe slot at which the propagation shader expects three volumes for red, green and blue spherical harmonic components.

References assert_hr, dune::exchange(), and dune::safe_release().


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