Page MenuHome
Paste P366

Choose scrambling distance for pixel-based sequence scrambling in Cycles
ActivePublic

Authored by Lukas Stockner (lukasstockner97) on Jun 10 2016, 9:59 PM.
Tags
None
Tokens
"Yellow Medal" token, awarded by juang3d."Dislike" token, awarded by lordodin.
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 1408627..4d92e4b 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -254,6 +254,14 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
default='SOBOL',
)
+ cls.scrambling_distance = FloatProperty(
+ name="Scrambling distance",
+ description="The amount of pixel-dependent scrambling applied to the Sobol sequence,"
+ "lower values might speed up rendering but can cause visible artifacts",
+ min=0.0, max=1.0,
+ default=1.0,
+ )
+
cls.use_layer_samples = EnumProperty(
name="Layer Samples",
description="How to use per render layer sample settings",
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 0961c34..74230f4 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -197,7 +197,10 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
sub.prop(cscene, "volume_samples", text="Volume")
if not (use_opencl(context) and cscene.feature_set != 'EXPERIMENTAL'):
- layout.row().prop(cscene, "sampling_pattern", text="Pattern")
+ col = layout.row().column()
+ col.prop(cscene, "sampling_pattern", text="Pattern")
+ col.prop(cscene, "scrambling_distance")
+
for rl in scene.render.layers:
if rl.samples > 0:
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 33084f1..e711264 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -268,6 +268,7 @@ void BlenderSync::sync_integrator()
"sampling_pattern",
SAMPLING_NUM_PATTERNS,
SAMPLING_PATTERN_SOBOL);
+ integrator->scrambling_distance = get_float(cscene, "scrambling_distance");
integrator->sample_clamp_direct = get_float(cscene, "sample_clamp_direct");
integrator->sample_clamp_indirect = get_float(cscene, "sample_clamp_indirect");
diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h
index 631a2cb..0ae26d7 100644
--- a/intern/cycles/kernel/kernel_random.h
+++ b/intern/cycles/kernel/kernel_random.h
@@ -128,6 +128,8 @@ ccl_device_inline float path_rng_1D(KernelGlobals *kg, ccl_addr_space RNG *rng,
else
shift = (*rng & 0xFFFF) * (1.0f/(float)0xFFFF);
+ shift *= kernel_data.integrator.scrambling_distance;
+
return r + shift - floorf(r + shift);
#endif
}
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 1ffcfb9..28033a9 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -1094,14 +1094,13 @@ typedef struct KernelIntegrator {
/* sampler */
int sampling_pattern;
int aa_samples;
+ float scrambling_distance;
/* volume render */
int use_volumes;
int volume_max_steps;
float volume_step_size;
int volume_samples;
-
- int pad;
} KernelIntegrator;
typedef struct KernelBVH {
diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp
index 2a10eb4..ed501ae 100644
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@ -75,6 +75,7 @@ NODE_DEFINE(Integrator)
sampling_pattern_enum.insert("sobol", SAMPLING_PATTERN_SOBOL);
sampling_pattern_enum.insert("cmj", SAMPLING_PATTERN_CMJ);
SOCKET_ENUM(sampling_pattern, "Sampling Pattern", sampling_pattern_enum, SAMPLING_PATTERN_SOBOL);
+ SOCKET_FLOAT(scrambling_distance, "Scrambling Distance", 1.0f);
return type;
}
@@ -162,6 +163,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
}
kintegrator->sampling_pattern = sampling_pattern;
+ kintegrator->scrambling_distance = scrambling_distance;
kintegrator->aa_samples = aa_samples;
/* sobol directions table */
diff --git a/intern/cycles/render/integrator.h b/intern/cycles/render/integrator.h
index 39eaaf2..88dbd18 100644
--- a/intern/cycles/render/integrator.h
+++ b/intern/cycles/render/integrator.h
@@ -77,6 +77,7 @@ public:
Method method;
SamplingPattern sampling_pattern;
+ float scrambling_distance;
bool need_update;

Event Timeline

Lukas Stockner (lukasstockner97) changed the title of this paste from untitled to Choose scrambling distance for pixel-based sequence scrambling in Cycles.
Lukas Stockner (lukasstockner97) updated the paste's language from autodetect to diff.

Small but gives nice time savings. Nice patch :)

Edit: Works great with OpenCL on latest master.