This repository was archived by the owner on Apr 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathLightSctrPostProcess.h
More file actions
174 lines (133 loc) · 7.35 KB
/
LightSctrPostProcess.h
File metadata and controls
174 lines (133 loc) · 7.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <D3DX11.h>
#include <D3DX10math.h>
#include "RenderTechnique.h"
#include "structures.fxh"
struct SFrameAttribs
{
ID3D11Device *pd3dDevice;
ID3D11DeviceContext *pd3dDeviceContext;
SLightAttribs LightAttribs;
SCameraAttribs CameraAttribs;
ID3D11ShaderResourceView *ptex2DSrcColorBufferSRV;
ID3D11ShaderResourceView *ptex2DDepthBufferSRV;
ID3D11ShaderResourceView *ptex2DShadowMapSRV;
ID3D11ShaderResourceView *ptex2DStainedGlassSRV;
ID3D11RenderTargetView *pDstRTV;
ID3D11DepthStencilView *pDstDSV;
};
#undef float4
#undef float3
#undef float2
#include <atlcomcli.h>
class CLightSctrPostProcess
{
public:
CLightSctrPostProcess();
~CLightSctrPostProcess();
HRESULT OnCreateDevice(ID3D11Device* in_pd3dDevice,
ID3D11DeviceContext *in_pd3dDeviceContext);
void OnDestroyDevice();
HRESULT OnResizedSwapChain(ID3D11Device* pd3dDevice, UINT uiBackBufferWidth, UINT uiBackBufferHeight);
void PerformPostProcessing(SFrameAttribs &FrameAttribs,
SPostProcessingAttribs &PPAttribs);
void ComputeSunColor(const D3DXVECTOR3 &vDirectionOnSun,
D3DXVECTOR4 &f4SunColorAtGround,
D3DXVECTOR4 &f4AmbientLight);
private:
HRESULT CreateDownscaledInscatteringTextures(ID3D11Device* pd3dDevice, UINT Width, UINT Height);
void ReconstructCameraSpaceZ(SFrameAttribs &FrameAttribs);
void RenderSliceEndpoints(SFrameAttribs &FrameAttribs);
void RenderCoordinateTexture(SFrameAttribs &FrameAttribs);
void RefineSampleLocations(SFrameAttribs &FrameAttribs);
void MarkRayMarchingSamples(SFrameAttribs &FrameAttribs);
void Build1DMinMaxMipMap(SFrameAttribs &FrameAttribs);
void DoRayMarching(SFrameAttribs &FrameAttribs, UINT uiMaxStepsAlongRay);
void InterpolateInsctrIrradiance(SFrameAttribs &FrameAttribs);
void UnwarpEpipolarScattering(SFrameAttribs &FrameAttribs);
void FixInscatteringAtDepthBreaks(SFrameAttribs &FrameAttribs, bool bAttenuateBackground, UINT uiMaxStepsAlongRay);
void UpscaleInscatteringRadiance(SFrameAttribs &FrameAttribs);
void RenderSampleLocations(SFrameAttribs &FrameAttribs);
void DefineMacros(class CD3DShaderMacroHelper &Macros);
SPostProcessingAttribs m_PostProcessingAttribs;
UINT m_uiSampleRefinementCSThreadGroupSize;
UINT m_uiSampleRefinementCSMinimumThreadGroupSize;
CComPtr<ID3D11ShaderResourceView> m_ptex2DSliceEndpointsSRV;
CComPtr<ID3D11RenderTargetView> m_ptex2DSliceEndpointsRTV;
CComPtr<ID3D11ShaderResourceView> m_ptex2DCoordianteTextureSRV;
CComPtr<ID3D11RenderTargetView> m_ptex2DCoordianteTextureRTV;
CComPtr<ID3D11DepthStencilView> m_ptex2DEpipolarImageDSV;
CComPtr<ID3D11ShaderResourceView> m_ptex2DEpipolarCamSpaceZSRV;
CComPtr<ID3D11RenderTargetView> m_ptex2DEpipolarCamSpaceZRTV;
CComPtr<ID3D11ShaderResourceView> m_ptex2DInterpolationSourcesSRV;
CComPtr<ID3D11UnorderedAccessView> m_ptex2DInterpolationSourcesUAV;
CComPtr<ID3D11ShaderResourceView> m_ptex2DInitialScatteredLightSRV;
CComPtr<ID3D11RenderTargetView> m_ptex2DInitialScatteredLightRTV;
CComPtr<ID3D11ShaderResourceView> m_ptex2DScatteredLightSRV;
CComPtr<ID3D11RenderTargetView> m_ptex2DScatteredLightRTV;
CComPtr<ID3D11ShaderResourceView> m_ptex2DCameraSpaceZSRV;
CComPtr<ID3D11RenderTargetView> m_ptex2DCameraSpaceZRTV;
CComPtr<ID3D11ShaderResourceView> m_ptex2DDownscaledScatteredLightSRV;
CComPtr<ID3D11RenderTargetView> m_ptex2DDownscaledScatteredLightRTV;
CComPtr<ID3D11ShaderResourceView> m_ptex2DSliceUVDirAndOriginSRV;
CComPtr<ID3D11RenderTargetView> m_ptex2DSliceUVDirAndOriginRTV;
CComPtr<ID3D11ShaderResourceView> m_ptex2DMinMaxShadowMapSRV[2];
CComPtr<ID3D11RenderTargetView> m_ptex2DMinMaxShadowMapRTV[2];
CComPtr<ID3D11ShaderResourceView> m_ptex2DPrecomputedPointLightInsctrSRV;
HRESULT CreateTextures(ID3D11Device* pd3dDevice);
HRESULT CreateMinMaxShadowMap(ID3D11Device* pd3dDevice);
HRESULT CreatePrecomputedPointLightInscatteringTexture(ID3D11Device* pd3dDevice, ID3D11DeviceContext *pd3dDeviceContext);
CComPtr<ID3D11DepthStencilView> m_ptex2DScreenSizeDSV;
CComPtr<ID3D11DepthStencilView> m_ptex2DDownscaledDSV;
UINT m_uiBackBufferWidth, m_uiBackBufferHeight;
LPCTSTR m_strEffectPath;
CComPtr<ID3D11VertexShader> m_pGenerateScreenSizeQuadVS;
CRenderTechnique m_ReconstrCamSpaceZTech;
CRenderTechnique m_RendedSliceEndpointsTech;
CRenderTechnique m_RendedCoordTexTech;
CRenderTechnique m_RefineSampleLocationsTech;
CRenderTechnique m_MarkRayMarchingSamplesInStencilTech;
CRenderTechnique m_RenderSliceUVDirInSMTech;
CRenderTechnique m_InitializeMinMaxShadowMapTech;
CRenderTechnique m_ComputeMinMaxSMLevelTech;
CRenderTechnique m_DoRayMarchTech[2]; // 0 - min/max optimization disabled; 1 - min/max optimization enabled
CRenderTechnique m_InterpolateIrradianceTech;
CRenderTechnique m_UnwarpEpipolarSctrImgTech[2]; // 0 - Unwarp inscattering image from epipolar coordinates only
// 1 - Unwarp inscattering image from epipolar coordinates to rectangular + apply it to attenuate background
CRenderTechnique m_FixInsctrAtDepthBreaksTech[2]; // 0 - Fix inscattering image at depth breaks by doing ray marching only
// 1 - Fix inscattering image + apply it to attenuate background
CRenderTechnique m_UpscaleInsctrdRadianceTech;
CRenderTechnique m_RenderSampleLocationsTech;
CComPtr<ID3D11SamplerState> m_psamLinearClamp;
CComPtr<ID3D11SamplerState> m_psamLinearBorder0;
CComPtr<ID3D11SamplerState> m_psamLinearUClampVWrap;
CComPtr<ID3D11SamplerState> m_psamComparison;
CComPtr<ID3D11DepthStencilState> m_pDisableDepthTestDS;
CComPtr<ID3D11DepthStencilState> m_pDisableDepthTestIncrStencilDS;
CComPtr<ID3D11DepthStencilState> m_pNoDepth_StEqual_IncrStencilDS;
CComPtr<ID3D11RasterizerState> m_pSolidFillNoCullRS;
CComPtr<ID3D11BlendState> m_pDefaultBS;
void ComputeScatteringCoefficients(ID3D11DeviceContext *pDeviceCtx = NULL);
const float m_fTurbidity;
SParticipatingMediaScatteringParams m_MediaParams;
CComPtr<ID3D11Buffer> m_pcbCameraAttribs;
CComPtr<ID3D11Buffer> m_pcbLightAttribs;
CComPtr<ID3D11Buffer> m_pcbPostProcessingAttribs;
CComPtr<ID3D11Buffer> m_pcbMediaAttribs;
CComPtr<ID3D11Buffer> m_pcbMiscParams;
};