The Dirtchamber
A mixed reality testing environment for real-time global illumination algorithms
light.h
Go to the documentation of this file.
1 /*
2  * Dune D3D library - Tobias Alexander Franke 2013
3  * For copyright and license see LICENSE
4  * http://www.tobias-franke.eu
5  */
6 
9 #ifndef DUNE_LIGHT
10 #define DUNE_LIGHT
11 
12 #include <D3D11.h>
13 
14 #include "cbuffer.h"
15 #include "gbuffer.h"
16 
17 namespace dune
18 {
29  {
30  public:
31  struct param
32  {
33  DirectX::XMFLOAT4 position;
34  DirectX::XMFLOAT4 direction;
35  DirectX::XMFLOAT4 flux;
36  DirectX::XMFLOAT4X4 vp;
37  DirectX::XMFLOAT4X4 vp_inv;
38  DirectX::XMFLOAT4X4 vp_tex;
39  };
40 
41  protected:
42  gbuffer rsm_;
43 
44  typedef cbuffer<param> cb_param;
45  cb_param cb_param_;
46 
47  public:
48  virtual void create(ID3D11Device* device);
49 
50  virtual void create(ID3D11Device* device, const tstring& name,
51  const DXGI_SURFACE_DESC& colors, const DXGI_SURFACE_DESC& normals, const DXGI_SURFACE_DESC& depth);
52 
53  virtual void create(ID3D11Device* device, const tstring& name,
54  const D3D11_TEXTURE2D_DESC& colors, const D3D11_TEXTURE2D_DESC& normals, const D3D11_TEXTURE2D_DESC& depth);
55 
56  virtual void destroy();
57 
59 
60  cb_param& parameters() { return cb_param_; }
61  const cb_param& parameters() const { return cb_param_; }
63 
65  void update(const DirectX::XMFLOAT4& upt, const DirectX::XMMATRIX& light_proj);
66 
67  gbuffer& rsm();
68  void prepare_render(ID3D11DeviceContext* context);
69  };
70 
83  {
84  protected:
85  gbuffer mu_;
86 
87  public:
89  gbuffer& rho() { return rsm(); }
90 
92  gbuffer& mu() { return mu_; }
93 
94  virtual void create(ID3D11Device* device, const tstring& name,
95  const D3D11_TEXTURE2D_DESC& colors, const D3D11_TEXTURE2D_DESC& normals, const D3D11_TEXTURE2D_DESC& depth);
96 
97  virtual void destroy();
98  };
99 
100  /*
101  class point_light : public shader_resource
102  {
103  };
104 
105  class environment_light : public shader_resource
106  {
107  };
108  */
109 }
110 
111 #endif
void update(const DirectX::XMFLOAT4 &upt, const DirectX::XMMATRIX &light_proj)
Update the view-projection matrix in the parameter cbuffer for shadowmap/RSM rendering.
Definition: light.cpp:14
A simple directional light source with an RSM.
Definition: light.h:28
A differential directional light source.
Definition: light.h:82
cb_param & parameters()
Return local cbuffer parameters.
Definition: light.h:60
gbuffer & mu()
Return RSM \( \mu \).
Definition: light.h:92
const cb_param & parameters() const
Return local cbuffer parameters.
Definition: light.h:61
A geometry buffer (collection of render_target objects).
Definition: gbuffer.h:30
gbuffer & rho()
Return RSM \( \rho \).
Definition: light.h:89