Skip to content

Commit

Permalink
refine DLS cache settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Theverat committed Jun 28, 2018
1 parent f73aeb9 commit 24615a7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 38 deletions.
16 changes: 9 additions & 7 deletions export/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import errno
from math import degrees
import bpy
from collections import OrderedDict
from ..bin import pyluxcore
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
})
35 changes: 15 additions & 20 deletions properties/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
EnumProperty, BoolProperty, IntProperty, FloatProperty,
PointerProperty, StringProperty,
)
from math import radians


TILED_DESCRIPTION = (
Expand Down Expand Up @@ -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):
Expand Down
30 changes: 19 additions & 11 deletions ui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 24615a7

Please sign in to comment.