-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGroundTruthAberration.h
253 lines (199 loc) · 8.29 KB
/
GroundTruthAberration.h
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#pragma once
////////////////////////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////////////////////////
#include "PCH.h"
#include "Common.h"
#include "WavefrontAberration.h"
////////////////////////////////////////////////////////////////////////////////
/// GROUND TRUTH ABERRATION FUNCTIONS
////////////////////////////////////////////////////////////////////////////////
namespace GroundTruthAberration
{
////////////////////////////////////////////////////////////////////////////////
/** Component and display name. */
static constexpr const char* COMPONENT_NAME = "GroundTruthAberration";
static constexpr const char* DISPLAY_NAME = "Ground Truth Aberration";
static constexpr const char* CATEGORY = "Aberration";
////////////////////////////////////////////////////////////////////////////////
struct ConvolutionSettings
{
// Input dynamic range
meta_enum(InputDynamicRange, int, HDR, LDR);
// What blend mode should be used
meta_enum(Algorithm, int, PerPixel, PerPixelStack, DepthLayers);
// What blend mode should be used
meta_enum(BlendMode, int, Sum, FrontToBack, BackToFront);
// What should be printed out
meta_enum(PrintDetail, int, Nothing, Progress, Detailed);
// Number of channels to render
int m_numChannels = 3;
// What precision to use for incident angles
float m_incidentAnglesPrecision = 0.1;
// What precision to use for object distance binning
float m_dioptresPrecision = 1e-2f;
// Whether incident angles should be centered on the region or not
bool m_centerIncidentAngles = false;
// Whether dioptres should be centered on the region or not
bool m_centerDioptres = false;
// Whether we should simulate off axis aberrations as well or not
bool m_simulateOffAxis = false;
// Whether we should export the psfs or not
bool m_exportPsfs = false;
// Whether we should be writing to log files during convolution or not
bool m_omitFileLogging = true;
// Type of input to use
InputDynamicRange m_inputDynamicRange;
// Which GT algorithm to run
Algorithm m_algorithm = PerPixel;
// The blend mode to use
BlendMode m_blendMode = Sum;
// What to print out
PrintDetail m_printDetail = Progress;
// Put computer to sleep mode when done
bool m_sleepWhenDone = false;
};
////////////////////////////////////////////////////////////////////////////////
struct MetricSettings
{
// HDR-VDP parameters
float m_hdrvdpPeakLuminance = 400.0f;
float m_hdrvdpContrastRatio = 1000.0f;
float m_hdrvdpGamma = 2.2f;
float m_hdrvdpAmbientLight = 100.0f;
float m_hdrvdpDisplaySize = 28.0f;
glm::ivec2 m_hdrvdpDisplayResolution{ 3840, 2160 };
float m_hdrvdpViewDistance = 1.0f;
float m_hdrvdpSurround = 13.0f;
float m_hdrvdpSensitivityCorrection = -0.3f;
// Whether we should export result of the metric computations or not
bool m_exportMetrics = false;
};
////////////////////////////////////////////////////////////////////////////////
// Structure holding all the simulation results
struct Results
{
// The various output modes available, mainly for debugging
meta_enum(ResultAttribute, int,
Scene,
Original,
Convolution,
Depth,
BlurRadius,
Normalization,
NumberOfSamples,
IncidentAngles,
Defocus,
BinIncidentAngles,
BinDefocus,
Reference,
Difference,
Ssim,
SsimJet,
HdrVdp3,
HdrVdp3Jet);
std::string m_timestampDisplay;
std::string m_timestampFile;
std::string m_aberration;
std::string m_scene;
std::string m_camera;
int m_width = -1;
int m_height = -1;
int m_channels = -1;
float m_incidentAnglesPrecision = 0.0f;
float m_dioptresPrecision = -1;
bool m_centerIncidentAngles = false;
bool m_centerDioptres = false;
int m_numBins = -1;
float m_apertureDiameter = -1.0f;
float m_focusDistance = -1.0f;
bool m_simulateOffAxis = false;
bool m_isHdr = false;
ConvolutionSettings::Algorithm m_algorithm = ConvolutionSettings::PerPixel;
ConvolutionSettings::BlendMode m_blendMode = ConvolutionSettings::Sum;
int m_numDepthSlices;
float m_minDepth = FLT_MAX;
float m_maxDepth = -FLT_MAX;
glm::vec4 m_minWeight = glm::vec4(FLT_MAX);
glm::vec4 m_maxWeight = glm::vec4(-FLT_MAX);
glm::ivec4 m_minNumSamples = glm::ivec4(INT_MAX);
glm::ivec4 m_maxNumSamples = glm::ivec4(-INT_MAX);
glm::vec4 m_minDefocus = glm::vec4(FLT_MAX);
glm::vec4 m_maxDefocus = glm::vec4(-FLT_MAX);
glm::vec4 m_minBlurRadius = glm::vec4(FLT_MAX);
glm::vec4 m_maxBlurRadius = glm::vec4(-FLT_MAX);
// HDR-VDP probability of detection
float m_hdrvdp;
// Per-channel and average mean structural similarity
glm::vec3 m_mssim;
float m_mmssim;
// Per-channel and average peak signal-to-noise and signal-to-noise ratio
glm::vec3 m_psnr;
glm::vec3 m_snr;
float m_mpsnr;
float m_msnr;
// Per-channel and average mean-squared error and root-mean-squared error
glm::vec3 m_mse;
glm::vec3 m_rmse;
float m_mmse;
float m_mrmse;
// Processing time
float m_psfBinTime = 0.0f;
float m_convolutionTime = 0.0f;
float m_totalProcessingTime = 0.0f;
// Resulting images
std::unordered_map<ResultAttribute, std::vector<unsigned char>> m_textures;
};
////////////////////////////////////////////////////////////////////////////////
struct OutputSettings
{
// Which result to show
Results::ResultAttribute m_outputMode = Results::Scene;
// Which result to use for rendering
int m_resultRenderId = 0;
// Which result to use for previewing
int m_resultTooltipId = 0;
};
////////////////////////////////////////////////////////////////////////////////
/** Component for splatting a dense set of PSFs. */
struct GroundTruthAberrationComponent
{
// Convolution settings
ConvolutionSettings m_convolutionSettings;
// Metric settings
MetricSettings m_metricSettings;
// Output settings
OutputSettings m_outputSettings;
// The aberration that we are simulating
Aberration::WavefrontAberration m_aberration;
// ---- Private members
// File logging state before the process was started
Debug::LogChannels m_fileLogState;
// All the aberration presets available.
Aberration::WavefrontAberrationPresets m_aberrationPresets;
// List of previously generated results
std::vector<Results> m_results;
};
////////////////////////////////////////////////////////////////////////////////
void loadPreviousResults(Scene::Scene& scene, Scene::Object* object);
////////////////////////////////////////////////////////////////////////////////
void initObject(Scene::Scene& scene, Scene::Object& object);
////////////////////////////////////////////////////////////////////////////////
void releaseObject(Scene::Scene& scene, Scene::Object& object);
////////////////////////////////////////////////////////////////////////////////
void updateObject(Scene::Scene& scene, Scene::Object* simulationSettings, Scene::Object* object);
////////////////////////////////////////////////////////////////////////////////
bool renderObjectPreconditionLDROpenGL(Scene::Scene& scene, Scene::Object* simulationSettings, Scene::Object* renderSettings, Scene::Object* camera, std::string const& functionName, Scene::Object* object);
////////////////////////////////////////////////////////////////////////////////
bool renderObjectPreconditionHDROpenGL(Scene::Scene& scene, Scene::Object* simulationSettings, Scene::Object* renderSettings, Scene::Object* camera, std::string const& functionName, Scene::Object* object);
////////////////////////////////////////////////////////////////////////////////
void renderObjectOpenGL(Scene::Scene& scene, Scene::Object* simulationSettings, Scene::Object* renderSettings, Scene::Object* camera, std::string const& functionName, Scene::Object* object);
////////////////////////////////////////////////////////////////////////////////
void generateGui(Scene::Scene& scene, Scene::Object* guiSettings, Scene::Object* object);
////////////////////////////////////////////////////////////////////////////////
void demoSetup(Scene::Scene& scene);
}
////////////////////////////////////////////////////////////////////////////////
// Component declaration
DECLARE_COMPONENT(GROUND_TRUTH_ABERRATION, GroundTruthAberrationComponent, GroundTruthAberration::GroundTruthAberrationComponent)
DECLARE_OBJECT(GROUND_TRUTH_ABERRATION, COMPONENT_ID_GROUND_TRUTH_ABERRATION, COMPONENT_ID_EDITOR_SETTINGS)