Skip to content

Commit

Permalink
double the amount of spp for tiled path singlepass if the denoiser is…
Browse files Browse the repository at this point in the history
… used
  • Loading branch information
Theverat committed Nov 24, 2018
1 parent 988748e commit b8f47d9
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion export/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions export/halt.py
Original file line number Diff line number Diff line change
@@ -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 = ""
Expand All @@ -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:
Expand All @@ -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)
3 changes: 2 additions & 1 deletion properties/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
3 changes: 3 additions & 0 deletions ui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ui/denoiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b8f47d9

Please sign in to comment.