From b8f47d97fe5ddc8f06b1fc7c03dcbd6561df2f0b Mon Sep 17 00:00:00 2001 From: Simon Wendsche Date: Sat, 24 Nov 2018 23:57:09 +0100 Subject: [PATCH] double the amount of spp for tiled path singlepass if the denoiser is used --- export/config.py | 2 +- export/halt.py | 28 ++++++++++++++-------------- properties/config.py | 3 ++- ui/config.py | 3 +++ ui/denoiser.py | 2 +- utils/__init__.py | 9 +++++++++ 6 files changed, 30 insertions(+), 17 deletions(-) diff --git a/export/config.py b/export/config.py index 19af3439..798e0c9f 100644 --- a/export/config.py +++ b/export/config.py @@ -187,7 +187,7 @@ def _convert_final_engine(scene, definitions, config): definitions["tilepath.sampling.aa.size"] = tile.path_sampling_aa_size definitions["tile.size"] = tile.size - definitions["tile.multipass.enable"] = tile.multipass_enable + definitions["tile.multipass.enable"] = tile.multipass_enable or utils.use_two_tiled_passes(scene) thresh = tile.multipass_convtest_threshold definitions["tile.multipass.convergencetest.threshold"] = thresh thresh_reduct = tile.multipass_convtest_threshold_reduction diff --git a/export/halt.py b/export/halt.py index 9276ca76..34e78a1f 100644 --- a/export/halt.py +++ b/export/halt.py @@ -1,5 +1,8 @@ from .. import utils +# noise threshold has to be a little greater than 0 +SMALLEST_NOISE_THRESH = 0.0001 + def convert(scene): prefix = "" @@ -13,24 +16,14 @@ def convert(scene): use_noise_thresh = halt.enable and halt.use_noise_thresh definitions["batch.haltthreshold.stoprendering.enable"] = use_noise_thresh - # noise threshold has to be a little greater than 0 - SMALLEST_NOISE_THRESH = 0.0001 - if not use_noise_thresh: # Set a very low noise threshold so final renders use # the adaptive sampling to full advantage definitions["batch.haltthreshold"] = SMALLEST_NOISE_THRESH if halt.enable: - if halt.use_time: - definitions["batch.halttime"] = halt.time - else: - definitions["batch.halttime"] = 0 - - if halt.use_samples: - definitions["batch.haltspp"] = halt.samples - else: - definitions["batch.haltspp"] = 0 + halt_time = halt.time if halt.use_time else 0 + halt_spp = halt.samples if halt.use_samples else 0 if halt.use_noise_thresh: if halt.noise_thresh == 0: @@ -46,7 +39,14 @@ def convert(scene): # All halt conditions disabled. # Note that we have to explicitly set halttime and haltspp to 0 because # these properties are not deleted during a session parsing. - definitions["batch.halttime"] = 0 - definitions["batch.haltspp"] = 0 + halt_time = 0 + halt_spp = 0 + + if utils.use_two_tiled_passes(scene): + aa = scene.luxcore.config.tile.path_sampling_aa_size + halt_spp = max(halt_spp, 2 * aa**2) + + definitions["batch.haltspp"] = halt_spp + definitions["batch.halttime"] = halt_time return utils.create_props(prefix, definitions) diff --git a/properties/config.py b/properties/config.py index c4dbb1f7..29a36dea 100644 --- a/properties/config.py +++ b/properties/config.py @@ -16,7 +16,8 @@ ) AA_SAMPLE_DESC = ( - "How many samples to compute per pass. Higher values increase memory usage, but lead to better performance" + "How many samples to compute per pass. Higher values increase memory usage, but lead to better performance. " + "Note that this number is squared, so e.g. a value of 5 will lead to 25 samples per pixel after one pass" ) THRESH_REDUCT_DESC = ( diff --git a/ui/config.py b/ui/config.py index 07d65e95..2759d661 100644 --- a/ui/config.py +++ b/ui/config.py @@ -65,6 +65,9 @@ def draw(self, context): row.prop(config.tile, "size") row.prop(config.tile, "path_sampling_aa_size") + if utils.use_two_tiled_passes(context.scene): + layout.label("(Doubling amount of samples because of denoiser)") + layout.prop(config.tile, "multipass_enable") if config.tile.multipass_enable: col = layout.column(align=True) diff --git a/ui/denoiser.py b/ui/denoiser.py index cb3fde6d..1708bdb6 100644 --- a/ui/denoiser.py +++ b/ui/denoiser.py @@ -12,7 +12,7 @@ def draw(context, layout): col = layout.column() if denoiser.enabled: - if config.sampler == "METROPOLIS": + if config.sampler == "METROPOLIS" and not config.use_tiles: col.label("Metropolis sampler can lead to artifacts!", icon=icons.WARNING) if config.engine == "BIDIR" and config.filter != "NONE": col.label('Set filter to "None" to reduce blurriness', icon=icons.WARNING) diff --git a/utils/__init__.py b/utils/__init__.py index c55e2407..86eae41d 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -551,6 +551,15 @@ def get_halt_conditions(scene): return scene.luxcore.halt +def use_two_tiled_passes(scene): + # When combining the denoiser with tilepath in singlepass mode, we have to render + # two passes (twice as many samples) because the first pass is needed as denoiser + # warmup, and only during the second pass can the denoiser collect sample information. + config = scene.luxcore.config + using_tilepath = config.engine == "PATH" and config.use_tiles + return scene.luxcore.denoiser.enabled and using_tilepath and not config.tile.multipass_enable + + def pluralize(format_str, amount): formatted = format_str % amount if amount != 1: