Skip to content

Commit 62026b9

Browse files
committed
Changed some settings
1 parent 9a971ef commit 62026b9

12 files changed

Lines changed: 83 additions & 56 deletions

File tree

src/backend/runtime/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ set(SRC
1414
Runtime.h
1515
RuntimeInfo.cpp
1616
RuntimeInfo.h
17+
RuntimeSettings.h
18+
RuntimeStructs.h
1719
SceneObject.h
1820
SHA256.cpp
1921
SHA256.h

src/backend/runtime/Runtime.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,14 @@ bool Runtime::load(const std::filesystem::path& path, Parser::Scene&& scene)
206206
lopts.IsTracer = mOptions.IsTracer;
207207
lopts.Scene = std::move(scene);
208208
lopts.ForceSpecialization = mOptions.ForceSpecialization;
209-
lopts.UseDenoiser = !mOptions.IsTracer && mOptions.UseDenoiser && hasDenoiser();
209+
lopts.Denoiser = mOptions.Denoiser;
210+
lopts.Denoiser.Enabled = !mOptions.IsTracer && mOptions.Denoiser.Enabled && hasDenoiser();
210211

211212
// Print a warning if denoiser was requested but none is available
212-
if (mOptions.UseDenoiser && !lopts.UseDenoiser && !mOptions.IsTracer && hasDenoiser())
213+
if (mOptions.Denoiser.Enabled && !lopts.Denoiser.Enabled && !mOptions.IsTracer && hasDenoiser())
213214
IG_LOG(L_WARNING) << "Trying to use denoiser but no denoiser is available" << std::endl;
214215

215-
if (lopts.UseDenoiser)
216+
if (lopts.Denoiser.Enabled)
216217
IG_LOG(L_INFO) << "Using denoiser" << std::endl;
217218

218219
// Extract technique
@@ -249,7 +250,7 @@ bool Runtime::load(const std::filesystem::path& path, Parser::Scene&& scene)
249250
mTechniqueVariants = std::move(result.TechniqueVariants);
250251
mResourceMap = std::move(result.ResourceMap);
251252

252-
if (lopts.UseDenoiser)
253+
if (lopts.Denoiser.Enabled)
253254
mTechniqueInfo.EnabledAOVs.emplace_back("Denoised");
254255

255256
return setup();
@@ -296,7 +297,7 @@ void Runtime::stepVariant(bool ignoreDenoiser, size_t variant, bool lastVariant)
296297
DriverRenderSettings settings;
297298
settings.rays = nullptr; // No artificial ray streams
298299
settings.device = mDevice;
299-
settings.apply_denoiser = mOptions.UseDenoiser && !ignoreDenoiser;
300+
settings.apply_denoiser = mOptions.Denoiser.Enabled && !ignoreDenoiser;
300301
settings.spi = info.GetSPI(mSamplesPerIteration);
301302
settings.work_width = info.GetWidth(mFilmWidth);
302303
settings.work_height = info.GetHeight(mFilmHeight);

src/backend/runtime/Runtime.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include "RuntimeSettings.h"
34
#include "RuntimeStructs.h"
45
#include "Statistics.h"
56
#include "driver/DriverManager.h"
@@ -14,29 +15,6 @@ class Scene;
1415

1516
struct LoaderOptions;
1617

17-
struct RuntimeOptions {
18-
bool IsTracer = false;
19-
bool IsInteractive = false;
20-
bool DumpShader = false;
21-
bool DumpShaderFull = false;
22-
bool AcquireStats = false;
23-
Target DesiredTarget = Target::INVALID;
24-
bool RecommendCPU = true;
25-
bool RecommendGPU = true;
26-
bool UseDenoiser = false;
27-
uint32 Device = 0;
28-
uint32 SPI = 0; // Detect automatically
29-
std::string OverrideTechnique;
30-
std::string OverrideCamera;
31-
std::pair<uint32, uint32> OverrideFilmSize = { 0, 0 };
32-
33-
bool AddExtraEnvLight = false; // User option to add a constant environment light (just to see something)
34-
std::filesystem::path ModulePath = std::filesystem::current_path(); // Optional path to modules
35-
std::filesystem::path ScriptDir = {}; // Path to a new script directory, replacing the internal standard library
36-
37-
bool ForceSpecialization = false; // Enforce specialization of generated shader for all parameters. This will increase compile time
38-
};
39-
4018
struct AOVAccessor {
4119
const float* Data;
4220
size_t IterationCount;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#pragma once
2+
3+
#include "Target.h"
4+
5+
namespace IG {
6+
struct DenoiserSettings {
7+
bool Enabled = false; // Enables the denoiser
8+
bool FollowSpecular = false; // Follow specular paths instead of only using the first bounce for AOV information
9+
bool OnlyFirstIteration = true; // Acquire AOV information only at the first iteration, or refine every iteration
10+
};
11+
12+
struct RuntimeOptions {
13+
bool IsTracer = false;
14+
bool IsInteractive = false;
15+
bool DumpShader = false;
16+
bool DumpShaderFull = false;
17+
bool AcquireStats = false;
18+
Target DesiredTarget = Target::INVALID;
19+
bool RecommendCPU = true;
20+
bool RecommendGPU = true;
21+
uint32 Device = 0;
22+
uint32 SPI = 0; // Detect automatically
23+
std::string OverrideTechnique;
24+
std::string OverrideCamera;
25+
std::pair<uint32, uint32> OverrideFilmSize = { 0, 0 };
26+
27+
bool AddExtraEnvLight = false; // User option to add a constant environment light (just to see something)
28+
std::filesystem::path ModulePath = std::filesystem::current_path(); // Optional path to modules
29+
std::filesystem::path ScriptDir = {}; // Path to a new script directory, replacing the internal standard library
30+
31+
bool ForceSpecialization = false; // Enforce specialization of generated shader for all parameters. This will increase compile time
32+
33+
DenoiserSettings Denoiser;
34+
};
35+
} // namespace IG

src/backend/runtime/RuntimeStructs.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ struct ParameterSet {
3535
std::unordered_map<std::string, Vector4f> ColorParameters;
3636
};
3737

38-
struct RuntimeRenderSettings {
39-
size_t FilmWidth = 800;
40-
size_t FilmHeight = 600;
41-
};
42-
4338
struct Ray {
4439
Vector3f Origin;
4540
Vector3f Direction;

src/backend/runtime/loader/Loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bool Loader::load(const LoaderOptions& opts, LoaderResult& result)
2727
ctx.PixelSamplerType = opts.PixelSamplerType;
2828
ctx.SamplesPerIteration = opts.SamplesPerIteration;
2929
ctx.IsTracer = opts.IsTracer;
30-
ctx.UseDenoiser = opts.UseDenoiser;
30+
ctx.Denoiser = opts.Denoiser;
3131
ctx.FilmWidth = opts.FilmWidth;
3232
ctx.FilmHeight = opts.FilmHeight;
3333
ctx.Lights = std::make_unique<LoaderLight>();

src/backend/runtime/loader/Loader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "CameraOrientation.h"
44
#include "Parser.h"
5+
#include "RuntimeSettings.h"
56
#include "Target.h"
67
#include "TechniqueInfo.h"
78
#include "table/SceneDatabase.h"
@@ -21,7 +22,7 @@ struct LoaderOptions {
2122
size_t SamplesPerIteration; // Only a recommendation!
2223
bool IsTracer;
2324
bool ForceSpecialization;
24-
bool UseDenoiser;
25+
DenoiserSettings Denoiser;
2526
};
2627

2728
struct LoaderResult {

src/backend/runtime/loader/LoaderContext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include "LoaderEnvironment.h"
4+
#include "RuntimeSettings.h"
45
#include "Target.h"
56
#include "TechniqueInfo.h"
67

@@ -27,7 +28,7 @@ struct LoaderContext {
2728
std::string PixelSamplerType;
2829
IG::TechniqueInfo TechniqueInfo;
2930

30-
bool UseDenoiser = false; // TODO: Make use of this
31+
DenoiserSettings Denoiser;
3132
bool IsTracer = false;
3233

3334
size_t CurrentTechniqueVariant;

src/backend/runtime/loader/LoaderTechnique.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static TechniqueInfo wireframe_get_info(const std::string&, const std::shared_pt
7373

7474
/////////////////////////
7575

76-
static void enable_ib(TechniqueInfo& info, bool extend = true)
76+
static void enable_ib(TechniqueInfo& info, bool always = false, bool extend = true)
7777
{
7878
info.EnabledAOVs.emplace_back("Normals");
7979
info.EnabledAOVs.emplace_back("Albedo");
@@ -90,7 +90,7 @@ static void enable_ib(TechniqueInfo& info, bool extend = true)
9090
if (info.VariantSelector) {
9191
const auto prevSelector = info.VariantSelector;
9292
info.VariantSelector = [=](size_t iter) {
93-
if (iter == 0) {
93+
if (always || iter == 0) {
9494
std::vector<size_t> pass_with_ib = prevSelector(iter);
9595
pass_with_ib.emplace_back(variantCount - 1);
9696
return pass_with_ib;
@@ -100,7 +100,7 @@ static void enable_ib(TechniqueInfo& info, bool extend = true)
100100
};
101101
} else {
102102
info.VariantSelector = [=](size_t iter) {
103-
if (iter == 0) {
103+
if (always || iter == 0) {
104104
std::vector<size_t> pass_with_ib(variantCount);
105105
std::iota(std::begin(pass_with_ib), std::end(pass_with_ib), 0);
106106
return pass_with_ib;
@@ -126,7 +126,7 @@ static bool handle_ib_body(std::ostream& stream, const std::shared_ptr<Parser::O
126126
return false;
127127

128128
const int max_depth = technique ? technique->property("max_depth").getInteger(64) : 64;
129-
const bool handle_specular = technique ? technique->property("denoiser_handle_specular").getBool(false) : false;
129+
const bool handle_specular = ctx.Denoiser.FollowSpecular || (technique ? technique->property("denoiser_handle_specular").getBool(false) : false);
130130

131131
stream << " let aov_normals = device.load_aov_image(\"Normals\", spi); aov_normals.mark_as_used();" << std::endl;
132132
stream << " let aov_albedo = device.load_aov_image(\"Albedo\", spi); aov_albedo.mark_as_used();" << std::endl;
@@ -164,10 +164,12 @@ static bool handle_ib_header(std::ostream& stream, const LoaderContext& ctx)
164164
return true;
165165
}
166166

167-
static TechniqueInfo ib_get_info(const std::string&, const std::shared_ptr<Parser::Object>&, const LoaderContext&)
167+
static TechniqueInfo ib_get_info(const std::string&, const std::shared_ptr<Parser::Object>& technique, const LoaderContext& ctx)
168168
{
169+
const bool apply_always = !ctx.Denoiser.OnlyFirstIteration || (technique ? technique->property("denoiser_ib_all_iterations").getBool(false) : false);
170+
169171
TechniqueInfo info;
170-
enable_ib(info, false);
172+
enable_ib(info, apply_always, false);
171173
return info;
172174
}
173175

@@ -199,8 +201,8 @@ static TechniqueInfo path_get_info(const std::string&, const std::shared_ptr<Par
199201

200202
info.Variants[0].UsesLights = true;
201203

202-
if (ctx.UseDenoiser)
203-
enable_ib(info);
204+
if (ctx.Denoiser.Enabled)
205+
enable_ib(info, !ctx.Denoiser.OnlyFirstIteration);
204206

205207
return info;
206208
}
@@ -256,8 +258,8 @@ static TechniqueInfo volpath_get_info(const std::string&, const std::shared_ptr<
256258
info.Variants[0].UsesLights = true;
257259
info.Variants[0].UsesMedia = true;
258260

259-
if (ctx.UseDenoiser)
260-
enable_ib(info);
261+
if (ctx.Denoiser.Enabled)
262+
enable_ib(info, !ctx.Denoiser.OnlyFirstIteration);
261263

262264
return info;
263265
}
@@ -355,8 +357,8 @@ static TechniqueInfo ppm_get_info(const std::string&, const std::shared_ptr<Pars
355357
}
356358
}
357359

358-
if (ctx.UseDenoiser)
359-
enable_ib(info);
360+
if (ctx.Denoiser.Enabled)
361+
enable_ib(info, !ctx.Denoiser.OnlyFirstIteration);
360362

361363
return info;
362364
}

src/frontend/common/ProgramOptions.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,21 @@ ProgramOptions::ProgramOptions(int argc, char** argv, ApplicationType type, cons
137137
app.add_flag("--add-env-light", AddExtraEnvLight, "Add additional constant environment light. This is automatically done for glTF scenes without any lights");
138138
app.add_flag("--force-specialization", ForceSpecialization, "Enforce specialization for parameters in shading tree. This will increase compile time drastically for potential runtime optimization");
139139

140-
if (type != ApplicationType::Trace)
140+
if (type != ApplicationType::Trace) {
141+
if (type == ApplicationType::CLI) {
142+
// Focus on quality
143+
DenoiserFollowSpecular = true;
144+
DenoiserOnlyFirstIteration = false;
145+
} else {
146+
// Focus on interactivity
147+
DenoiserFollowSpecular = false;
148+
DenoiserOnlyFirstIteration = true;
149+
}
150+
141151
app.add_flag("--denoise", Denoise, "Apply denoiser if available");
152+
app.add_flag("--denoiser-follow-specular,!--denoiser-skip-specular", DenoiserFollowSpecular, "Follow specular paths or terminate at them");
153+
app.add_flag("--denoiser-aov-first-iteration,!--denoiser-aov-every-iteration", DenoiserOnlyFirstIteration, "Acquire scene normal, albedo and depth information every iteration or only at the first");
154+
}
142155

143156
if (type == ApplicationType::Trace) {
144157
app.add_option("-i,--input", InputRay, "Read list of rays from file instead of the standard input");
@@ -181,7 +194,9 @@ void ProgramOptions::populate(RuntimeOptions& options) const
181194
options.AddExtraEnvLight = AddExtraEnvLight;
182195
options.ForceSpecialization = ForceSpecialization;
183196

184-
options.UseDenoiser = Denoise;
197+
options.Denoiser.Enabled = Denoise;
198+
options.Denoiser.FollowSpecular = DenoiserFollowSpecular;
199+
options.Denoiser.OnlyFirstIteration = DenoiserOnlyFirstIteration;
185200

186201
options.ScriptDir = ScriptDir;
187202
}

0 commit comments

Comments
 (0)