[Bf-blender-cvs] [c9238e638fd] master: Cycles: add back control to render first N bounces with path termination

Brecht Van Lommel noreply at git.blender.org
Fri Jun 28 17:51:58 CEST 2019


Commit: c9238e638fd5f6b3e4cf22d879d397dee1b09b48
Author: Brecht Van Lommel
Date:   Fri Jun 28 17:06:32 2019 +0200
Branches: master
https://developer.blender.org/rBc9238e638fd5f6b3e4cf22d879d397dee1b09b48

Cycles: add back control to render first N bounces with path termination

It's found in the Sampling > Advanced panel and 0 by default. This helps to
reduce noise in some scenes, while making others slower.

===================================================================

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

===================================================================

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index d9e145c8b75..c5cedf2ed9b 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -291,6 +291,21 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
         default=0.01,
     )
 
+    min_light_bounces: IntProperty(
+            name="Min Light Bounces",
+            description="Minimum number of light bounces. Setting this higher reduces noise in the first bounces, "
+                        "but can also be less efficient for more complex geometry like hair and volumes",
+            min=0, max=1024,
+            default=0,
+    )
+    min_transparent_bounces: IntProperty(
+            name="Min Transparent Bounces",
+            description="Minimum number of transparnet bounces. Setting this higher reduces noise in the first bounces, "
+                        "but can also be less efficient for more complex geometry like hair and volumes",
+            min=0, max=1024,
+            default=0,
+    )
+
     caustics_reflective: BoolProperty(
         name="Reflective Caustics",
         description="Use reflective caustics, resulting in a brighter image (more noise but added realism)",
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 0dc1e815335..b072d9e583e 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -237,6 +237,8 @@ class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
         layout.separator()
 
         col = layout.column(align=True)
+        col.prop(cscene, "min_light_bounces")
+        col.prop(cscene, "min_transparent_bounces")
         col.prop(cscene, "light_sampling_threshold", text="Light Threshold")
 
         if cscene.progressive != 'PATH' and use_branched_path(context):
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 95ecb4200c2..bac571b02ce 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -235,6 +235,7 @@ void BlenderSync::sync_integrator()
   Integrator *integrator = scene->integrator;
   Integrator previntegrator = *integrator;
 
+  integrator->min_bounce = get_int(cscene, "min_light_bounces");
   integrator->max_bounce = get_int(cscene, "max_bounces");
 
   integrator->max_diffuse_bounce = get_int(cscene, "diffuse_bounces");
@@ -242,6 +243,7 @@ void BlenderSync::sync_integrator()
   integrator->max_transmission_bounce = get_int(cscene, "transmission_bounces");
   integrator->max_volume_bounce = get_int(cscene, "volume_bounces");
 
+  integrator->transparent_min_bounce = get_int(cscene, "min_transparent_bounces");
   integrator->transparent_max_bounce = get_int(cscene, "transparent_max_bounces");
 
   integrator->volume_max_steps = get_int(cscene, "volume_max_steps");
diff --git a/intern/cycles/kernel/kernel_path_state.h b/intern/cycles/kernel/kernel_path_state.h
index cdca0b1f9bf..8735e3208db 100644
--- a/intern/cycles/kernel/kernel_path_state.h
+++ b/intern/cycles/kernel/kernel_path_state.h
@@ -209,8 +209,8 @@ ccl_device_inline float path_state_continuation_probability(KernelGlobals *kg,
     return 0.0f;
   }
   else if (state->flag & PATH_RAY_TRANSPARENT) {
-    /* Do at least one bounce without RR. */
-    if (state->transparent_bounce <= 1) {
+    /* Do at least specified number of bounces without RR. */
+    if (state->transparent_bounce <= kernel_data.integrator.transparent_min_bounce) {
       return 1.0f;
     }
 #ifdef __SHADOW_TRICKS__
@@ -221,8 +221,8 @@ ccl_device_inline float path_state_continuation_probability(KernelGlobals *kg,
 #endif
   }
   else {
-    /* Do at least one bounce without RR. */
-    if (state->bounce <= 1) {
+    /* Do at least specified number of bounces without RR. */
+    if (state->bounce <= kernel_data.integrator.min_bounce) {
       return 1.0f;
     }
 #ifdef __SHADOW_TRICKS__
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index b93af6c068c..a1d950bbc70 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -1271,6 +1271,7 @@ typedef struct KernelIntegrator {
   int portal_offset;
 
   /* bounces */
+  int min_bounce;
   int max_bounce;
 
   int max_diffuse_bounce;
@@ -1281,6 +1282,7 @@ typedef struct KernelIntegrator {
   int ao_bounces;
 
   /* transparent */
+  int transparent_min_bounce;
   int transparent_max_bounce;
   int transparent_shadows;
 
@@ -1325,7 +1327,7 @@ typedef struct KernelIntegrator {
 
   int max_closures;
 
-  int pad1, pad2, pad3;
+  int pad1;
 } KernelIntegrator;
 static_assert_align(KernelIntegrator, 16);
 
diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp
index d3873dcfe46..76258a292e8 100644
--- a/intern/cycles/render/integrator.cpp
+++ b/intern/cycles/render/integrator.cpp
@@ -32,6 +32,7 @@ NODE_DEFINE(Integrator)
 {
   NodeType *type = NodeType::add("integrator", create);
 
+  SOCKET_INT(min_bounce, "Min Bounce", 0);
   SOCKET_INT(max_bounce, "Max Bounce", 7);
 
   SOCKET_INT(max_diffuse_bounce, "Max Diffuse Bounce", 7);
@@ -39,6 +40,7 @@ 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", 0);
   SOCKET_INT(transparent_max_bounce, "Transparent Max Bounce", 7);
 
   SOCKET_INT(ao_bounces, "AO Bounces", 0);
@@ -100,6 +102,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
   KernelIntegrator *kintegrator = &dscene->data.integrator;
 
   /* integrator parameters */
+  kintegrator->min_bounce = min_bounce + 1;
   kintegrator->max_bounce = max_bounce + 1;
 
   kintegrator->max_diffuse_bounce = max_diffuse_bounce + 1;
@@ -107,6 +110,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
   kintegrator->max_transmission_bounce = max_transmission_bounce + 1;
   kintegrator->max_volume_bounce = max_volume_bounce + 1;
 
+  kintegrator->transparent_min_bounce = transparent_min_bounce + 1;
   kintegrator->transparent_max_bounce = transparent_max_bounce + 1;
 
   if (ao_bounces == 0) {
diff --git a/intern/cycles/render/integrator.h b/intern/cycles/render/integrator.h
index 6acc68a7402..32d84c27072 100644
--- a/intern/cycles/render/integrator.h
+++ b/intern/cycles/render/integrator.h
@@ -31,6 +31,7 @@ class Integrator : public Node {
  public:
   NODE_DECLARE
 
+  int min_bounce;
   int max_bounce;
 
   int max_diffuse_bounce;
@@ -38,6 +39,7 @@ class Integrator : public Node {
   int max_transmission_bounce;
   int max_volume_bounce;
 
+  int transparent_min_bounce;
   int transparent_max_bounce;
 
   int ao_bounces;
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 757aa8048b0..8e7969cfbaf 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -396,7 +396,7 @@ void ImageTextureNode::compile(OSLCompiler &compiler)
 
   if (slot == -1) {
     compiler.parameter_texture(
-        "filename", filename, compress_as_srgb ? known_colorspace : u_colorspace_raw);
+        "filename", filename, compress_as_srgb ? u_colorspace_raw : known_colorspace);
   }
   else {
     compiler.parameter_texture("filename", slot);
@@ -584,7 +584,7 @@ void EnvironmentTextureNode::compile(OSLCompiler &compiler)
 
   if (slot == -1) {
     compiler.parameter_texture(
-        "filename", filename, compress_as_srgb ? known_colorspace : u_colorspace_raw);
+        "filename", filename, compress_as_srgb ? u_colorspace_raw : known_colorspace);
   }
   else {
     compiler.parameter_texture("filename", slot);



More information about the Bf-blender-cvs mailing list