Cycles: remove min bounces, modify RR to terminate less.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 2 Aug 2017 20:53:55 +0000 (22:53 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 4 Aug 2017 21:11:03 +0000 (23:11 +0200)
Differential Revision: https://developer.blender.org/D2766

intern/cycles/blender/addon/presets.py
intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_sync.cpp
intern/cycles/kernel/kernel_path_state.h
intern/cycles/kernel/kernel_types.h
intern/cycles/render/integrator.cpp
intern/cycles/render/integrator.h

index 82c4ffc6e5058efe31e7e5fe18b7857930adea12..440221b847098d0886b26a88aa3d323d91a84716 100644 (file)
@@ -32,12 +32,10 @@ class AddPresetIntegrator(AddPresetBase, Operator):
 
     preset_values = [
         "cycles.max_bounces",
-        "cycles.min_bounces",
         "cycles.diffuse_bounces",
         "cycles.glossy_bounces",
         "cycles.transmission_bounces",
         "cycles.volume_bounces",
-        "cycles.transparent_min_bounces",
         "cycles.transparent_max_bounces",
         "cycles.use_transparent_shadows",
         "cycles.caustics_reflective",
index 68474529ed309d70d53951e229399dd16b915926..cb5b13f8d3a5005ff284ad9ac7977c9cf12a9c85 100644 (file)
@@ -311,14 +311,6 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
                 default=0.0,
                 )
 
-        cls.min_bounces = IntProperty(
-                name="Min Bounces",
-                description="Minimum number of bounces, setting this lower "
-                            "than the maximum enables probabilistic path "
-                            "termination (faster but noisier)",
-                min=0, max=1024,
-                default=3,
-                )
         cls.max_bounces = IntProperty(
                 name="Max Bounces",
                 description="Total maximum number of bounces",
@@ -351,15 +343,6 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
                 default=0,
                 )
 
-        cls.transparent_min_bounces = IntProperty(
-                name="Transparent Min Bounces",
-                description="Minimum number of transparent bounces, setting "
-                            "this lower than the maximum enables "
-                            "probabilistic path termination (faster but "
-                            "noisier)",
-                min=0, max=1024,
-                default=8,
-                )
         cls.transparent_max_bounces = IntProperty(
                 name="Transparent Max Bounces",
                 description="Maximum number of transparent bounces",
index 49beebe5ab4739b5ba5098faedc342db7f9728f1..45a77aa8c383fe57a2bbe5a525dd8442a5858e08 100644 (file)
@@ -292,7 +292,6 @@ class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel):
         sub = col.column(align=True)
         sub.label("Transparency:")
         sub.prop(cscene, "transparent_max_bounces", text="Max")
-        sub.prop(cscene, "transparent_min_bounces", text="Min")
         sub.prop(cscene, "use_transparent_shadows", text="Shadows")
 
         col.separator()
@@ -306,7 +305,6 @@ class CyclesRender_PT_light_paths(CyclesButtonsPanel, Panel):
         sub = col.column(align=True)
         sub.label(text="Bounces:")
         sub.prop(cscene, "max_bounces", text="Max")
-        sub.prop(cscene, "min_bounces", text="Min")
 
         sub = col.column(align=True)
         sub.prop(cscene, "diffuse_bounces", text="Diffuse")
index 3a00384458a74919fc4c51031ac6a9f0d29c759f..ddaa962f63d8fef959265f275335ff0d8194e40b 100644 (file)
@@ -234,7 +234,6 @@ void BlenderSync::sync_integrator()
        Integrator *integrator = scene->integrator;
        Integrator previntegrator = *integrator;
 
-       integrator->min_bounce = get_int(cscene, "min_bounces");
        integrator->max_bounce = get_int(cscene, "max_bounces");
 
        integrator->max_diffuse_bounce = get_int(cscene, "diffuse_bounces");
@@ -243,7 +242,6 @@ void BlenderSync::sync_integrator()
        integrator->max_volume_bounce = get_int(cscene, "volume_bounces");
 
        integrator->transparent_max_bounce = get_int(cscene, "transparent_max_bounces");
-       integrator->transparent_min_bounce = get_int(cscene, "transparent_min_bounces");
        integrator->transparent_shadows = get_boolean(cscene, "use_transparent_shadows");
 
        integrator->volume_max_steps = get_int(cscene, "volume_max_steps");
index 5d92fd1220177bedf54a461e77c60447480e0f71..a96ffe0771885b13112dcdc2fe3db9f67562f20b 100644 (file)
@@ -163,14 +163,23 @@ ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *s
 ccl_device_inline float path_state_terminate_probability(KernelGlobals *kg, ccl_addr_space PathState *state, const float3 throughput)
 {
        if(state->flag & PATH_RAY_TRANSPARENT) {
-               /* transparent rays treated separately */
-               if(state->transparent_bounce >= kernel_data.integrator.transparent_max_bounce)
+               /* Transparent rays are treated separately with own max bounces. */
+               if(state->transparent_bounce >= kernel_data.integrator.transparent_max_bounce) {
                        return 0.0f;
-               else if(state->transparent_bounce <= kernel_data.integrator.transparent_min_bounce)
+               }
+               /* Do at least one bounce without RR. */
+               else if(state->transparent_bounce <= 1) {
                        return 1.0f;
+               }
+#ifdef __SHADOW_TRICKS__
+               /* Exception for shadow catcher not working correctly with RR. */
+               else if ((state->flag & PATH_RAY_SHADOW_CATCHER) && (state->transparent_bounce <= 8)) {
+                       return 1.0f;
+               }
+#endif
        }
        else {
-               /* other rays */
+               /* Test max bounces for various ray types. */
                if((state->bounce >= kernel_data.integrator.max_bounce) ||
                   (state->diffuse_bounce >= kernel_data.integrator.max_diffuse_bounce) ||
                   (state->glossy_bounce >= kernel_data.integrator.max_glossy_bounce) ||
@@ -181,13 +190,21 @@ ccl_device_inline float path_state_terminate_probability(KernelGlobals *kg, ccl_
                {
                        return 0.0f;
                }
-               else if(state->bounce <= kernel_data.integrator.min_bounce) {
+               /* Do at least one bounce without RR. */
+               else if(state->bounce <= 1) {
                        return 1.0f;
                }
+#ifdef __SHADOW_TRICKS__
+               /* Exception for shadow catcher not working correctly with RR. */
+               else if ((state->flag & PATH_RAY_SHADOW_CATCHER) && (state->bounce <= 3)) {
+                       return 1.0f;
+               }
+#endif
        }
 
-       /* probalistic termination */
-       return average(throughput); /* todo: try using max here */
+       /* Probalistic termination: use sqrt() to roughly match typical view
+        * transform and do path termination a bit later on average. */
+       return sqrtf(max3(fabs(throughput)));
 }
 
 /* TODO(DingTo): Find more meaningful name for this */
index e6a62c42a38133fa6c5b6128f86b3ac07c66d16d..557ce5804f889e0d4b382935153038182549bf95 100644 (file)
@@ -1236,7 +1236,6 @@ typedef struct KernelIntegrator {
        int portal_offset;
 
        /* bounces */
-       int min_bounce;
        int max_bounce;
 
        int max_diffuse_bounce;
@@ -1247,7 +1246,6 @@ typedef struct KernelIntegrator {
        int ao_bounces;
 
        /* transparent */
-       int transparent_min_bounce;
        int transparent_max_bounce;
        int transparent_shadows;
 
@@ -1290,7 +1288,7 @@ typedef struct KernelIntegrator {
        float light_inv_rr_threshold;
 
        int start_sample;
-       int pad1, pad2, pad3;
+       int pad1;
 } KernelIntegrator;
 static_assert_align(KernelIntegrator, 16);
 
index a004bb5b856001942573d4da51bf896671a491e4..b9b8c681a262daaf2e0b2eaaf0b20ea4d9b5768a 100644 (file)
@@ -31,7 +31,6 @@ NODE_DEFINE(Integrator)
 {
        NodeType *type = NodeType::add("integrator", create);
 
-       SOCKET_INT(min_bounce, "Min Bounce", 2);
        SOCKET_INT(max_bounce, "Max Bounce", 7);
 
        SOCKET_INT(max_diffuse_bounce, "Max Diffuse Bounce", 7);
@@ -39,7 +38,6 @@ NODE_DEFINE(Integrator)
        SOCKET_INT(max_transmission_bounce, "Max Transmission Bounce", 7);
        SOCKET_INT(max_volume_bounce, "Max Volume Bounce", 7);
 
-       SOCKET_INT(transparent_min_bounce, "Transparent Min Bounce", 2);
        SOCKET_INT(transparent_max_bounce, "Transparent Max Bounce", 7);
        SOCKET_BOOLEAN(transparent_shadows, "Transparent Shadows", false);
 
@@ -104,7 +102,6 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
 
        /* integrator parameters */
        kintegrator->max_bounce = max_bounce + 1;
-       kintegrator->min_bounce = min_bounce + 1;
 
        kintegrator->max_diffuse_bounce = max_diffuse_bounce + 1;
        kintegrator->max_glossy_bounce = max_glossy_bounce + 1;
@@ -112,7 +109,6 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
        kintegrator->max_volume_bounce = max_volume_bounce + 1;
 
        kintegrator->transparent_max_bounce = transparent_max_bounce + 1;
-       kintegrator->transparent_min_bounce = transparent_min_bounce + 1;
 
        if(ao_bounces == 0) {
                kintegrator->ao_bounces = INT_MAX;
index 9501d7f84169b7472010ce82c1ba44c1e37a2f1a..ce5651ec823b6ee149cdfb4b57fcbc78fabb6352 100644 (file)
@@ -31,7 +31,6 @@ class Integrator : public Node {
 public:
        NODE_DECLARE
 
-       int min_bounce;
        int max_bounce;
 
        int max_diffuse_bounce;
@@ -39,7 +38,6 @@ public:
        int max_transmission_bounce;
        int max_volume_bounce;
 
-       int transparent_min_bounce;
        int transparent_max_bounce;
        bool transparent_shadows;