-
Notifications
You must be signed in to change notification settings - Fork 57
/
UserInterface.h
251 lines (202 loc) · 6.43 KB
/
UserInterface.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
/***************************************************************************
# Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
**************************************************************************/
#pragma once
#include <rtxdi/ReSTIRDI.h>
#include <rtxdi/ReGIRParameters.h>
#include <rtxdi/ReGIR.h>
#include <rtxdi/ReSTIRGI.h>
#include <donut/engine/Scene.h>
#include <donut/render/TemporalAntiAliasingPass.h>
#include <donut/app/imgui_renderer.h>
#include "GBufferPass.h"
#include "LightingPasses.h"
#if WITH_NRD
#include <NRD.h>
#endif
#include <optional>
#include <string>
class SampleScene;
namespace donut::engine {
struct IesProfile;
}
namespace donut::app {
class FirstPersonCamera;
}
enum class DirectLightingMode : uint32_t
{
None,
Brdf,
ReStir
};
enum class IndirectLightingMode : uint32_t
{
None,
Brdf,
ReStirGI
};
enum class QualityPreset : uint32_t
{
Custom = 0,
Fast = 1,
Medium = 2,
Unbiased = 3,
Ultra = 4,
Reference = 5
};
enum class AntiAliasingMode : uint32_t
{
None,
Accumulation,
TAA,
#ifdef WITH_DLSS
DLSS,
#endif
};
struct UIResources
{
std::shared_ptr<Profiler> profiler;
std::shared_ptr<SampleScene> scene;
donut::app::FirstPersonCamera* camera = nullptr;
std::vector<std::shared_ptr<donut::engine::IesProfile>> iesProfiles;
std::shared_ptr<donut::engine::Material> selectedMaterial;
};
enum DebugRenderOutput
{
LDRColor,
Depth,
GBufferDiffuseAlbedo,
GBufferSpecularRough,
GBufferNormals,
GBufferGeoNormals,
GBufferEmissive,
DiffuseLighting,
SpecularLighting,
DenoisedDiffuseLighting,
DenoisedSpecularLighting,
RestirLuminance,
PrevRestirLuminance,
DiffuseConfidence,
SpecularConfidence,
MotionVectors
};
struct UIData
{
bool reloadShaders = false;
bool resetAccumulation = false;
bool showUI = true;
bool isLoading = true;
float loadingPercentage = 0.f;
ibool enableTextures = true;
uint32_t framesToAccumulate = 0;
ibool enableToneMapping = true;
ibool enablePixelJitter = true;
ibool rasterizeGBuffer = true;
ibool useRayQuery = true;
ibool enableBloom = true;
float exposureBias = -1.0f;
float verticalFov = 60.f;
QualityPreset preset = QualityPreset::Medium;
#ifdef WITH_DLSS
AntiAliasingMode aaMode = AntiAliasingMode::DLSS;
#else
AntiAliasingMode aaMode = AntiAliasingMode::TAA;
#endif
uint32_t numAccumulatedFrames = 1;
DirectLightingMode directLightingMode = DirectLightingMode::ReStir;
IndirectLightingMode indirectLightingMode = IndirectLightingMode::None;
ibool enableAnimations = true;
float animationSpeed = 1.f;
int environmentMapDirty = 0; // 1 -> needs to be rendered; 2 -> passes/textures need to be created
int environmentMapIndex = -1;
bool environmentMapImportanceSampling = true;
float environmentIntensityBias = 0.f;
float environmentRotation = 0.f;
bool enableDenoiser = true;
#ifdef WITH_NRD
float debug = 0.0f;
nrd::Denoiser denoisingMethod = nrd::Denoiser::RELAX_DIFFUSE_SPECULAR;
nrd::ReblurSettings reblurSettings = {};
nrd::RelaxSettings relaxSettings = {};
void SetDefaultDenoiserSettings();
#endif
float noiseMix = 0.33f;
float noiseClampLow = 0.5f;
float noiseClampHigh = 2.0f;
#ifdef WITH_DLSS
bool dlssAvailable = false;
float dlssExposureScale = 2.f;
float dlssSharpness = 0.f;
#endif
float resolutionScale = 1.f;
bool enableFpsLimit = false;
uint32_t fpsLimit = 60;
rtxdi::ReSTIRDIStaticParameters restirDIStaticParams;
rtxdi::ReGIRStaticParameters regirStaticParams;
rtxdi::ReSTIRGIStaticParameters restirGIStaticParams;
rtxdi::ReGIRDynamicParameters regirDynamicParameters;
bool resetISContext = false;
uint32_t regirLightSlotCount = 0;
bool freezeRegirPosition = false;
std::optional<int> animationFrame;
std::string benchmarkResults;
uint32_t visualizationMode = 0; // See the VIS_MODE_XXX constants in ShaderParameters.h
uint32_t debugRenderOutputBuffer = 0; // See DebugRenderOutput enum above
bool storeReferenceImage = false;
bool referenceImageCaptured = false;
float referenceImageSplit = 0.f;
GBufferSettings gbufferSettings;
LightingPasses::RenderSettings lightingSettings;
struct
{
uint32_t numLocalLightUniformSamples = 8;
uint32_t numLocalLightPowerRISSamples = 8;
uint32_t numLocalLightReGIRRISSamples = 8;
rtxdi::ReSTIRDI_ResamplingMode resamplingMode;
ReSTIRDI_InitialSamplingParameters initialSamplingParams;
ReSTIRDI_TemporalResamplingParameters temporalResamplingParams;
ReSTIRDI_SpatialResamplingParameters spatialResamplingParams;
ReSTIRDI_ShadingParameters shadingParams;
} restirDI;
struct
{
rtxdi::ReSTIRGI_ResamplingMode resamplingMode;
ReSTIRGI_TemporalResamplingParameters temporalResamplingParams;
ReSTIRGI_SpatialResamplingParameters spatialResamplingParams;
ReSTIRGI_FinalShadingParameters finalShadingParams;
} restirGI;
donut::render::TemporalAntiAliasingParameters taaParams;
donut::render::TemporalAntiAliasingJitter temporalJitter = donut::render::TemporalAntiAliasingJitter::Halton;
std::unique_ptr<UIResources> resources = std::make_unique<UIResources>();
UIData();
void ApplyPreset();
};
class UserInterface : public donut::app::ImGui_Renderer
{
private:
UIData& m_ui;
ImFont* m_FontOpenSans = nullptr;
std::shared_ptr<donut::engine::Light> m_SelectedLight;
bool m_showAdvancedSamplingSettings = false;
bool m_showAdvancedDenoisingSettings = false;
void CopySelectedLight() const;
void CopyCamera() const;
void PerformanceWindow();
void SceneSettings();
void GeneralRenderingSettings();
void SamplingSettings();
void PostProcessSettings();
#ifdef WITH_NRD
void DenoiserSettings();
#endif
protected:
void buildUI(void) override;
public:
UserInterface(donut::app::DeviceManager* deviceManager, donut::vfs::IFileSystem& rootFS, UIData& ui);
};