This repository has been archived by the owner on Apr 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathStructures.fxh
201 lines (171 loc) · 6 KB
/
Structures.fxh
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/////////////////////////////////////////////////////////////////////////////////////////////
// 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.
/////////////////////////////////////////////////////////////////////////////////////////////
#ifndef _STRCUTURES_FXH_
#define _STRCUTURES_FXH_
#define PI 3.1415928f
#ifdef __cplusplus
# define float2 D3DXVECTOR2
# define float3 D3DXVECTOR3
# define float4 D3DXVECTOR4
# define uint UINT
#else
# define BOOL bool // Do not use bool, because sizeof(bool)==1 !
#endif
#ifdef __cplusplus
# define CHECK_STRUCT_ALIGNMENT(s) static_assert( sizeof(s) % 16 == 0, "sizeof("#s") is not multiple of 16" );
#else
# define CHECK_STRUCT_ALIGNMENT(s)
#endif
struct SLightAttribs
{
float4 f4DirOnLight;
float4 f4LightColorAndIntensity;
float4 f4AmbientLight;
float4 f4CameraUVAndDepthInShadowMap;
float4 f4LightScreenPos;
float4 f4LightWorldPos; // For point and spot lights only
float4 f4SpotLightAxisAndCosAngle; // For spot light only
BOOL bIsLightOnScreen;
float3 f3Dummy;
#ifdef __cplusplus
D3DXMATRIX mLightViewT;
D3DXMATRIX mLightProjT;
D3DXMATRIX mWorldToLightProjSpaceT;
D3DXMATRIX mCameraProjToLightProjSpaceT;
#else
matrix mLightView;
matrix mLightProj;
matrix mWorldToLightProjSpace;
matrix mCameraProjToLightProjSpace;
#endif
};
CHECK_STRUCT_ALIGNMENT(SLightAttribs);
struct SCameraAttribs
{
float4 f4CameraPos; ///< Camera world position
#ifdef __cplusplus
D3DXMATRIX mViewT;
D3DXMATRIX mProjT;
D3DXMATRIX mViewProjInvT;
#else
matrix mView;
matrix mProj;
matrix mViewProjInv;
#endif
};
CHECK_STRUCT_ALIGNMENT(SCameraAttribs);
#define ACCEL_STRUCT_NONE 0
#define ACCEL_STRUCT_MIN_MAX_TREE 1
#define ACCEL_STRUCT_BV_TREE 2
#define LIGHT_TYPE_DIRECTIONAL 0
#define LIGHT_TYPE_SPOT 1
#define LIGHT_TYPE_POINT 2
#define INSCTR_INTGL_EVAL_METHOD_MY_LUT 0
#define INSCTR_INTGL_EVAL_METHOD_SRNN05 1
#define INSCTR_INTGL_EVAL_METHOD_ANALYTIC 2
#define LIGHT_SCTR_TECHNIQUE_EPIPOLAR_SAMPLING 0
#define LIGHT_SCTR_TECHNIQUE_BRUTE_FORCE 1
struct SPostProcessingAttribs
{
uint m_uiNumEpipolarSlices;
uint m_uiMaxSamplesInSlice;
uint m_uiInitialSampleStepInSlice;
uint m_uiEpipoleSamplingDensityFactor;
float m_fRefinementThreshold;
float m_fDownscaleFactor;
// do not use bool, because sizeof(bool)==1 and as a result bool variables
// will be incorrectly mapped on GPU constant buffer
BOOL m_bShowSampling;
BOOL m_bCorrectScatteringAtDepthBreaks;
BOOL m_bShowDepthBreaks;
BOOL m_bStainedGlass;
BOOL m_bShowLightingOnly;
BOOL m_bOptimizeSampleLocations;
uint m_uiAccelStruct;
float m_fDistanceScaler;
float m_fMaxTracingDistance;
uint m_uiMaxShadowMapStep;
float2 m_f2ShadowMapTexelSize;
uint m_uiShadowMapResolution;
uint m_uiMinMaxShadowMapResolution;
uint m_uiLightType;
float m_fExposure;
uint m_uiInsctrIntglEvalMethod;
uint m_uiLightSctrTechnique;
BOOL m_bAnisotropicPhaseFunction;
float3 m_f3Dummy;
float4 m_f4RayleighBeta;
float4 m_f4MieBeta;
#ifdef __cplusplus
SPostProcessingAttribs() :
m_uiNumEpipolarSlices(1024),
m_uiMaxSamplesInSlice(512),
m_uiInitialSampleStepInSlice(16),
// Note that sampling near the epipole is very cheap since only a few steps
// required to perform ray marching
m_uiEpipoleSamplingDensityFactor(4),
m_fRefinementThreshold(0.02f),
m_fDownscaleFactor(1.f),
m_bShowSampling(FALSE),
m_bCorrectScatteringAtDepthBreaks(TRUE),
m_bShowDepthBreaks(FALSE),
m_bStainedGlass(FALSE),
m_bShowLightingOnly(FALSE),
m_bOptimizeSampleLocations(TRUE),
m_uiAccelStruct(ACCEL_STRUCT_MIN_MAX_TREE),
m_fDistanceScaler(1.f),
m_fMaxTracingDistance(20.f),
m_uiMaxShadowMapStep(16),
m_f2ShadowMapTexelSize(0,0),
m_uiMinMaxShadowMapResolution(0),
m_uiLightType(LIGHT_TYPE_SPOT),
m_fExposure(1.f),
m_uiInsctrIntglEvalMethod(INSCTR_INTGL_EVAL_METHOD_MY_LUT),
m_uiLightSctrTechnique(LIGHT_SCTR_TECHNIQUE_EPIPOLAR_SAMPLING),
m_bAnisotropicPhaseFunction(TRUE),
m_f4RayleighBeta( 5.8e-6f, 13.5e-6f, 33.1e-6f, 0.f ),
m_f4MieBeta(2.0e-5f, 2.0e-5f, 2.0e-5f, 0.f)
{}
#endif
};
CHECK_STRUCT_ALIGNMENT(SPostProcessingAttribs);
struct SParticipatingMediaScatteringParams
{
// Atmospheric light scattering constants
float4 f4TotalRayleighBeta;
float4 f4AngularRayleighBeta;
float4 f4TotalMieBeta;
float4 f4AngularMieBeta;
float4 f4HG_g; // = float4(1 - HG_g*HG_g, 1 + HG_g*HG_g, -2*HG_g, 1.0);
float4 f4SummTotalBeta;
#define INSCATTERING_MULTIPLIER 27.f/3.f ///< Light scattering constant - Inscattering multiplier
};
CHECK_STRUCT_ALIGNMENT(SParticipatingMediaScatteringParams);
struct SMiscDynamicParams
{
#ifdef __cplusplus
uint ui4SrcMinMaxLevelXOffset;
uint ui4SrcMinMaxLevelYOffset;
uint ui4DstMinMaxLevelXOffset;
uint ui4DstMinMaxLevelYOffset;
#else
uint4 ui4SrcDstMinMaxLevelOffset;
#endif
float fMaxStepsAlongRay; // Maximum number of steps during ray tracing
float3 f3Dummy; // Constant buffers must be 16-byte aligned
};
CHECK_STRUCT_ALIGNMENT(SMiscDynamicParams);
#endif //_STRCUTURES_FXH_