From 24615a74c6ce24c52732d04bc6b3603fdc1cba93 Mon Sep 17 00:00:00 2001 From: Simon Wendsche Date: Thu, 28 Jun 2018 18:44:01 +0200 Subject: [PATCH] refine DLS cache settings --- export/config.py | 16 +++++++++------- properties/config.py | 35 +++++++++++++++-------------------- ui/config.py | 30 +++++++++++++++++++----------- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/export/config.py b/export/config.py index 9e4a7f28..faab2c03 100644 --- a/export/config.py +++ b/export/config.py @@ -1,5 +1,6 @@ import os import errno +from math import degrees import bpy from collections import OrderedDict from ..bin import pyluxcore @@ -149,7 +150,7 @@ def convert(exporter, scene, context=None, engine=None): }) if config.light_strategy == "DLS_CACHE": - _convert_dlscache_settings(definitions, config) + _convert_dlscache_settings(scene, definitions, config) if config.path.use_clamping: definitions["path.clamping.variance.maxvalue"] = config.path.clamping @@ -270,17 +271,18 @@ def _convert_metropolis_settings(definitions, config): definitions["sampler.metropolis.imagemutationrate"] = config.metropolis_imagemutationrate / 100 -def _convert_dlscache_settings(definitions, config): +def _convert_dlscache_settings(scene, definitions, config): dls_cache = config.dls_cache + worldscale = utils.get_worldscale(scene, as_scalematrix=False) definitions.update({ - "lightstrategy.entry.radius": dls_cache.entry_radius, - "lightstrategy.entry.normalangle": dls_cache.entry_normalangle, + "lightstrategy.entry.radius": dls_cache.entry_radius * worldscale, + "lightstrategy.entry.normalangle": degrees(dls_cache.entry_normalangle), "lightstrategy.entry.maxpasses": dls_cache.entry_maxpasses, - "lightstrategy.entry.convergencethreshold": dls_cache.entry_convergencethreshold, + "lightstrategy.entry.convergencethreshold": dls_cache.entry_convergencethreshold / 100, "lightstrategy.entry.volumes.enable": dls_cache.entry_volumes_enable, - "lightstrategy.lightthreshold": dls_cache.lightthreshold, - "lightstrategy.targetcachehitratio": dls_cache.targetcachehitratio, + "lightstrategy.lightthreshold": dls_cache.lightthreshold / 100, + "lightstrategy.targetcachehitratio": dls_cache.targetcachehitratio, # TODO maybe divide by 100 later if Dade changes it "lightstrategy.maxdepth": dls_cache.maxdepth, "lightstrategy.maxsamplescount": dls_cache.maxsamplescount, }) diff --git a/properties/config.py b/properties/config.py index 79f7d9da..90c541b9 100644 --- a/properties/config.py +++ b/properties/config.py @@ -4,6 +4,7 @@ EnumProperty, BoolProperty, IntProperty, FloatProperty, PointerProperty, StringProperty, ) +from math import radians TILED_DESCRIPTION = ( @@ -140,28 +141,22 @@ class LuxCoreConfigTile(PropertyGroup): class LuxCoreConfigDLSCache(PropertyGroup): - # TODO remove this comment - # Property("lightstrategy.entry.radius")(.15f) << - # + Property("lightstrategy.entry.normalangle")(10.f) << - # + Property("lightstrategy.entry.maxpasses")(1024) << - # + Property("lightstrategy.entry.convergencethreshold")(.01f) << - # ("lightstrategy.entry.volumes.enable")(false) - # + Property("lightstrategy.lightthreshold")(.01f) << - # + Property("lightstrategy.targetcachehitratio")(99.5f) << - # + Property("lightstrategy.maxdepth")(4) << - # + Property("lightstrategy.maxsamplescount")(10000000); + show_advanced = BoolProperty(name="Show Advanced", default=False) # TODO names, min/max, percentage-type, descriptions - entry_radius = FloatProperty(default=0.15) - entry_normalangle = FloatProperty(default=10) - entry_maxpasses = IntProperty(default=1024) - entry_convergencethreshold = FloatProperty(default=0.01) - entry_volumes_enable = BoolProperty(default=False) - - lightthreshold = FloatProperty(default=0.01) - targetcachehitratio = FloatProperty(default=99.5) - maxdepth = IntProperty(default=4) - maxsamplescount = IntProperty(default=10000000) + entry_radius = FloatProperty(name="Entry Radius", default=0.15, subtype="DISTANCE") + entry_normalangle = FloatProperty(name="Normal Angle", + default=radians(10), min=0, max=radians(90), subtype="ANGLE") + entry_maxpasses = IntProperty(name="Max. Passes", default=1024) + entry_convergencethreshold = FloatProperty(name="Convergence Threshold", + default=1, min=0, max=100, subtype="PERCENTAGE") + entry_volumes_enable = BoolProperty(name="Place Entries in Volumes", default=False, + description="Enable/disable placement of entries in volumes") + + lightthreshold = FloatProperty(name="Light Threshold", default=1, min=0, max=100, subtype="PERCENTAGE") + targetcachehitratio = FloatProperty(name="Target Cache Hit Ratio", default=99.5, min=0, max=100, subtype="PERCENTAGE") + maxdepth = IntProperty(name="Max. Depth", default=4) + maxsamplescount = IntProperty(name="Max. Samples", default=10000000) class LuxCoreConfig(PropertyGroup): diff --git a/ui/config.py b/ui/config.py index e9244880..e00b3942 100644 --- a/ui/config.py +++ b/ui/config.py @@ -111,20 +111,28 @@ def draw(self, context): row.prop(config, "use_animated_seed", icon="TIME", toggle=True) # Light strategy - layout.prop(config, "light_strategy") + ls_layout = layout.box() if config.light_strategy == "DLS_CACHE" else layout + ls_layout.prop(config, "light_strategy") if config.light_strategy == "DLS_CACHE": dls_cache = config.dls_cache - box = layout.box() - box.prop(dls_cache, "entry_radius") - box.prop(dls_cache, "entry_normalangle") - box.prop(dls_cache, "entry_maxpasses") - box.prop(dls_cache, "entry_convergencethreshold") - box.prop(dls_cache, "entry_volumes_enable") - box.prop(dls_cache, "lightthreshold") - box.prop(dls_cache, "targetcachehitratio") - box.prop(dls_cache, "maxdepth") - box.prop(dls_cache, "maxsamplescount") + ls_layout.prop(dls_cache, "entry_radius") + ls_layout.prop(dls_cache, "show_advanced", toggle=True) + + if dls_cache.show_advanced: + col = ls_layout.column(align=True) + col.label("Entry Settings:") + col.prop(dls_cache, "entry_normalangle") + col.prop(dls_cache, "entry_maxpasses") + col.prop(dls_cache, "entry_convergencethreshold") + col.prop(dls_cache, "entry_volumes_enable") + + col = ls_layout.column(align=True) + col.label("General Cache Settings:") + col.prop(dls_cache, "lightthreshold") + col.prop(dls_cache, "targetcachehitratio") + col.prop(dls_cache, "maxdepth") + col.prop(dls_cache, "maxsamplescount") def draw_clamp_settings(self, layout, config): split = layout.split()