Cycles: perform clamping per light contribution instead of whole path
authorLukas Stockner <lukasstockner97>
Sun, 8 Dec 2019 20:19:37 +0000 (21:19 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 12 Dec 2019 12:04:43 +0000 (13:04 +0100)
With upcoming light group passes, for them to sum up correctly to the combined
pass the clamping must be more fine grained.

This also has the advantage that if one light is particularly noisy, it does
not diminish the contribution from other lights which do not need as much
clamping.

Clamp values on existing scenes will need to be tweaked to get similar results,
there is no automatic conversion possible which would give the same results as
before.

Implemented by Lukas, with tweaks by Brecht.

Part of D4837

15 files changed:
intern/cycles/kernel/kernel_accumulate.h
intern/cycles/kernel/kernel_bake.h
intern/cycles/kernel/kernel_emission.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_path_branched.h
intern/cycles/kernel/kernel_path_surface.h
intern/cycles/kernel/kernel_path_volume.h
intern/cycles/kernel/kernel_volume.h
intern/cycles/kernel/split/kernel_branched.h
intern/cycles/kernel/split/kernel_buffer_update.h
intern/cycles/kernel/split/kernel_path_init.h
intern/cycles/kernel/split/kernel_shadow_blocked_dl.h
intern/cycles/render/film.cpp
intern/cycles/render/film.h
intern/cycles/render/integrator.cpp

index 46a51f5a560671519117170cb073c05fdec98ca6..606c288649a44ed08ae17ce5b9597db8bae59982 100644 (file)
@@ -174,13 +174,13 @@ ccl_device_inline float3 bsdf_eval_sum(const BsdfEval *eval)
  * visible as the first non-transparent hit, while indirectly visible are the
  * bounces after that. */
 
-ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass)
+ccl_device_inline void path_radiance_init(KernelGlobals *kg, PathRadiance *L)
 {
   /* clear all */
 #ifdef __PASSES__
-  L->use_light_pass = use_light_pass;
+  L->use_light_pass = kernel_data.film.use_light_pass;
 
-  if (use_light_pass) {
+  if (kernel_data.film.use_light_pass) {
     L->indirect = make_float3(0.0f, 0.0f, 0.0f);
     L->direct_emission = make_float3(0.0f, 0.0f, 0.0f);
 
@@ -285,7 +285,37 @@ ccl_device_inline void path_radiance_bsdf_bounce(KernelGlobals *kg,
   }
 }
 
-ccl_device_inline void path_radiance_accum_emission(PathRadiance *L,
+#ifdef __CLAMP_SAMPLE__
+ccl_device_forceinline void path_radiance_clamp(KernelGlobals *kg, float3 *L, int bounce)
+{
+  float limit = (bounce > 0) ? kernel_data.integrator.sample_clamp_indirect :
+                               kernel_data.integrator.sample_clamp_direct;
+  float sum = reduce_add(fabs(*L));
+  if (sum > limit) {
+    *L *= limit / sum;
+  }
+}
+
+ccl_device_forceinline void path_radiance_clamp_throughput(KernelGlobals *kg,
+                                                           float3 *L,
+                                                           float3 *throughput,
+                                                           int bounce)
+{
+  float limit = (bounce > 0) ? kernel_data.integrator.sample_clamp_indirect :
+                               kernel_data.integrator.sample_clamp_direct;
+
+  float sum = reduce_add(fabs(*L));
+  if (sum > limit) {
+    float clamp_factor = limit / sum;
+    *L *= clamp_factor;
+    *throughput *= clamp_factor;
+  }
+}
+
+#endif
+
+ccl_device_inline void path_radiance_accum_emission(KernelGlobals *kg,
+                                                    PathRadiance *L,
                                                     ccl_addr_space PathState *state,
                                                     float3 throughput,
                                                     float3 value)
@@ -296,23 +326,29 @@ ccl_device_inline void path_radiance_accum_emission(PathRadiance *L,
   }
 #endif
 
+  float3 contribution = throughput * value;
+#ifdef __CLAMP_SAMPLE__
+  path_radiance_clamp(kg, &contribution, state->bounce - 1);
+#endif
+
 #ifdef __PASSES__
   if (L->use_light_pass) {
     if (state->bounce == 0)
-      L->emission += throughput * value;
+      L->emission += contribution;
     else if (state->bounce == 1)
-      L->direct_emission += throughput * value;
+      L->direct_emission += contribution;
     else
-      L->indirect += throughput * value;
+      L->indirect += contribution;
   }
   else
 #endif
   {
-    L->emission += throughput * value;
+    L->emission += contribution;
   }
 }
 
-ccl_device_inline void path_radiance_accum_ao(PathRadiance *L,
+ccl_device_inline void path_radiance_accum_ao(KernelGlobals *kg,
+                                              PathRadiance *L,
                                               ccl_addr_space PathState *state,
                                               float3 throughput,
                                               float3 alpha,
@@ -339,21 +375,23 @@ ccl_device_inline void path_radiance_accum_ao(PathRadiance *L,
   }
 #endif
 
+  float3 contribution = throughput * bsdf * ao;
+
 #ifdef __PASSES__
   if (L->use_light_pass) {
     if (state->bounce == 0) {
       /* Directly visible lighting. */
-      L->direct_diffuse += throughput * bsdf * ao;
+      L->direct_diffuse += contribution;
     }
     else {
       /* Indirectly visible lighting after BSDF bounce. */
-      L->indirect += throughput * bsdf * ao;
+      L->indirect += contribution;
     }
   }
   else
 #endif
   {
-    L->emission += throughput * bsdf * ao;
+    L->emission += contribution;
   }
 }
 
@@ -374,7 +412,8 @@ ccl_device_inline void path_radiance_accum_total_ao(PathRadiance *L,
 #endif
 }
 
-ccl_device_inline void path_radiance_accum_light(PathRadiance *L,
+ccl_device_inline void path_radiance_accum_light(KernelGlobals *kg,
+                                                 PathRadiance *L,
                                                  ccl_addr_space PathState *state,
                                                  float3 throughput,
                                                  BsdfEval *bsdf_eval,
@@ -394,15 +433,24 @@ ccl_device_inline void path_radiance_accum_light(PathRadiance *L,
   }
 #endif
 
+  float3 shaded_throughput = throughput * shadow;
+
 #ifdef __PASSES__
   if (L->use_light_pass) {
+    /* Compute the clamping based on the total contribution.
+     * The resulting scale is then be applied to all individual components. */
+    float3 full_contribution = shaded_throughput * bsdf_eval_sum(bsdf_eval);
+#  ifdef __CLAMP_SAMPLE__
+    path_radiance_clamp_throughput(kg, &full_contribution, &shaded_throughput, state->bounce);
+#  endif
+
     if (state->bounce == 0) {
       /* directly visible lighting */
-      L->direct_diffuse += throughput * bsdf_eval->diffuse * shadow;
-      L->direct_glossy += throughput * bsdf_eval->glossy * shadow;
-      L->direct_transmission += throughput * bsdf_eval->transmission * shadow;
-      L->direct_subsurface += throughput * bsdf_eval->subsurface * shadow;
-      L->direct_scatter += throughput * bsdf_eval->scatter * shadow;
+      L->direct_diffuse += shaded_throughput * bsdf_eval->diffuse;
+      L->direct_glossy += shaded_throughput * bsdf_eval->glossy;
+      L->direct_transmission += shaded_throughput * bsdf_eval->transmission;
+      L->direct_subsurface += shaded_throughput * bsdf_eval->subsurface;
+      L->direct_scatter += shaded_throughput * bsdf_eval->scatter;
 
       if (is_lamp) {
         L->shadow.x += shadow.x * shadow_fac;
@@ -412,13 +460,15 @@ ccl_device_inline void path_radiance_accum_light(PathRadiance *L,
     }
     else {
       /* indirectly visible lighting after BSDF bounce */
-      L->indirect += throughput * bsdf_eval_sum(bsdf_eval) * shadow;
+      L->indirect += full_contribution;
     }
   }
   else
 #endif
   {
-    L->emission += throughput * bsdf_eval->diffuse * shadow;
+    float3 contribution = shaded_throughput * bsdf_eval->diffuse;
+    path_radiance_clamp(kg, &contribution, state->bounce);
+    L->emission += contribution;
   }
 }
 
@@ -439,7 +489,8 @@ ccl_device_inline void path_radiance_accum_total_light(PathRadiance *L,
 #endif
 }
 
-ccl_device_inline void path_radiance_accum_background(PathRadiance *L,
+ccl_device_inline void path_radiance_accum_background(KernelGlobals *kg,
+                                                      PathRadiance *L,
                                                       ccl_addr_space PathState *state,
                                                       float3 throughput,
                                                       float3 value)
@@ -456,19 +507,24 @@ ccl_device_inline void path_radiance_accum_background(PathRadiance *L,
   }
 #endif
 
+  float3 contribution = throughput * value;
+#ifdef __CLAMP_SAMPLE__
+  path_radiance_clamp(kg, &contribution, state->bounce - 1);
+#endif
+
 #ifdef __PASSES__
   if (L->use_light_pass) {
     if (state->flag & PATH_RAY_TRANSPARENT_BACKGROUND)
-      L->background += throughput * value;
+      L->background += contribution;
     else if (state->bounce == 1)
-      L->direct_emission += throughput * value;
+      L->direct_emission += contribution;
     else
-      L->indirect += throughput * value;
+      L->indirect += contribution;
   }
   else
 #endif
   {
-    L->emission += throughput * value;
+    L->emission += contribution;
   }
 
 #ifdef __DENOISING_FEATURES__
@@ -587,8 +643,6 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg,
   /* Light Passes are used */
 #ifdef __PASSES__
   float3 L_direct, L_indirect;
-  float clamp_direct = kernel_data.integrator.sample_clamp_direct;
-  float clamp_indirect = kernel_data.integrator.sample_clamp_indirect;
   if (L->use_light_pass) {
     path_radiance_sum_indirect(L);
 
@@ -622,44 +676,6 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg,
 
       L->emission = make_float3(0.0f, 0.0f, 0.0f);
     }
-
-    /* Clamp direct and indirect samples */
-#  ifdef __CLAMP_SAMPLE__
-    else if (sum > clamp_direct || sum > clamp_indirect) {
-      float scale;
-
-      /* Direct */
-      float sum_direct = fabsf(L_direct.x) + fabsf(L_direct.y) + fabsf(L_direct.z);
-      if (sum_direct > clamp_direct) {
-        scale = clamp_direct / sum_direct;
-        L_direct *= scale;
-
-        L->direct_diffuse *= scale;
-        L->direct_glossy *= scale;
-        L->direct_transmission *= scale;
-        L->direct_subsurface *= scale;
-        L->direct_scatter *= scale;
-        L->emission *= scale;
-        L->background *= scale;
-      }
-
-      /* Indirect */
-      float sum_indirect = fabsf(L_indirect.x) + fabsf(L_indirect.y) + fabsf(L_indirect.z);
-      if (sum_indirect > clamp_indirect) {
-        scale = clamp_indirect / sum_indirect;
-        L_indirect *= scale;
-
-        L->indirect_diffuse *= scale;
-        L->indirect_glossy *= scale;
-        L->indirect_transmission *= scale;
-        L->indirect_subsurface *= scale;
-        L->indirect_scatter *= scale;
-      }
-
-      /* Sum again, after clamping */
-      L_sum = L_direct + L_indirect;
-    }
-#  endif
   }
 
   /* No Light Passes */
index 8e5a279e6cd8bebcf3f3b3112012a57490a85ce0..a349b225abb893e631ecc1b814df550f16937c9b 100644 (file)
@@ -39,7 +39,7 @@ ccl_device_inline void compute_light_pass(
 #  endif
 
   /* init radiance */
-  path_radiance_init(&L_sample, kernel_data.film.use_light_pass);
+  path_radiance_init(kg, &L_sample);
 
   /* init path state */
   path_state_init(kg, &emission_sd, &state, rng_hash, sample, NULL);
@@ -64,7 +64,7 @@ ccl_device_inline void compute_light_pass(
     /* sample emission */
     if ((pass_filter & BAKE_FILTER_EMISSION) && (sd->flag & SD_EMISSION)) {
       float3 emission = indirect_primitive_emission(kg, sd, 0.0f, state.flag, state.ray_pdf);
-      path_radiance_accum_emission(&L_sample, &state, throughput, emission);
+      path_radiance_accum_emission(kg, &L_sample, &state, throughput, emission);
     }
 
     bool is_sss_sample = false;
@@ -118,7 +118,7 @@ ccl_device_inline void compute_light_pass(
     /* sample emission */
     if ((pass_filter & BAKE_FILTER_EMISSION) && (sd->flag & SD_EMISSION)) {
       float3 emission = indirect_primitive_emission(kg, sd, 0.0f, state.flag, state.ray_pdf);
-      path_radiance_accum_emission(&L_sample, &state, throughput, emission);
+      path_radiance_accum_emission(kg, &L_sample, &state, throughput, emission);
     }
 
 #    ifdef __SUBSURFACE__
@@ -287,7 +287,7 @@ ccl_device void kernel_bake_evaluate(KernelGlobals *kg,
 
   /* light passes */
   PathRadiance L;
-  path_radiance_init(&L, kernel_data.film.use_light_pass);
+  path_radiance_init(kg, &L);
 
   shader_setup_from_sample(
       kg,
index e70958c2b068ed520227ee0f2227c1ec5e0c81fe..c63d1149d030bb4bda146ddf156916e2536ea81a 100644 (file)
@@ -234,14 +234,13 @@ ccl_device_noinline_cpu float3 indirect_primitive_emission(
 
 /* Indirect Lamp Emission */
 
-ccl_device_noinline_cpu bool indirect_lamp_emission(KernelGlobals *kg,
+ccl_device_noinline_cpu void indirect_lamp_emission(KernelGlobals *kg,
                                                     ShaderData *emission_sd,
                                                     ccl_addr_space PathState *state,
+                                                    PathRadiance *L,
                                                     Ray *ray,
-                                                    float3 *emission)
+                                                    float3 throughput)
 {
-  bool hit_lamp = false;
-
   for (int lamp = 0; lamp < kernel_data.integrator.num_all_lights; lamp++) {
     LightSample ls ccl_optional_struct_init;
 
@@ -261,7 +260,7 @@ ccl_device_noinline_cpu bool indirect_lamp_emission(KernelGlobals *kg,
     }
 #endif
 
-    float3 L = direct_emissive_eval(
+    float3 lamp_L = direct_emissive_eval(
         kg, emission_sd, &ls, state, -ray->D, ray->dD, ls.t, ray->time);
 
 #ifdef __VOLUME__
@@ -271,7 +270,7 @@ ccl_device_noinline_cpu bool indirect_lamp_emission(KernelGlobals *kg,
       volume_ray.t = ls.t;
       float3 volume_tp = make_float3(1.0f, 1.0f, 1.0f);
       kernel_volume_shadow(kg, emission_sd, state, &volume_ray, &volume_tp);
-      L *= volume_tp;
+      lamp_L *= volume_tp;
     }
 #endif
 
@@ -279,14 +278,11 @@ ccl_device_noinline_cpu bool indirect_lamp_emission(KernelGlobals *kg,
       /* multiple importance sampling, get regular light pdf,
        * and compute weight with respect to BSDF pdf */
       float mis_weight = power_heuristic(state->ray_pdf, ls.pdf);
-      L *= mis_weight;
+      lamp_L *= mis_weight;
     }
 
-    *emission += L;
-    hit_lamp = true;
+    path_radiance_accum_emission(kg, L, state, throughput, lamp_L);
   }
-
-  return hit_lamp;
 }
 
 /* Indirect Background */
index 693efad8c50102e43d7ea65b5286cf23ba7b94ef..1a0b67275a7fa592dc11696fcb4eaced48a8dfb5 100644 (file)
@@ -104,10 +104,7 @@ ccl_device_forceinline void kernel_path_lamp_emission(KernelGlobals *kg,
     light_ray.dP = ray->dP;
 
     /* intersect with lamp */
-    float3 emission = make_float3(0.0f, 0.0f, 0.0f);
-
-    if (indirect_lamp_emission(kg, emission_sd, state, &light_ray, &emission))
-      path_radiance_accum_emission(L, state, throughput, emission);
+    indirect_lamp_emission(kg, emission_sd, state, L, &light_ray, throughput);
   }
 #endif /* __LAMP_MIS__ */
 }
@@ -139,7 +136,7 @@ ccl_device_forceinline void kernel_path_background(KernelGlobals *kg,
 #ifdef __BACKGROUND__
   /* sample background shader */
   float3 L_background = indirect_background(kg, sd, state, buffer, ray);
-  path_radiance_accum_background(L, state, throughput, L_background);
+  path_radiance_accum_background(kg, L, state, throughput, L_background);
 #endif /* __BACKGROUND__ */
 }
 
@@ -189,7 +186,7 @@ ccl_device_forceinline VolumeIntegrateResult kernel_path_volume(KernelGlobals *k
 
     /* emission */
     if (volume_segment.closure_flag & SD_EMISSION)
-      path_radiance_accum_emission(L, state, *throughput, volume_segment.accum_emission);
+      path_radiance_accum_emission(kg, L, state, *throughput, volume_segment.accum_emission);
 
     /* scattering */
     VolumeIntegrateResult result = VOLUME_PATH_ATTENUATED;
@@ -321,7 +318,7 @@ ccl_device_forceinline bool kernel_path_shader_apply(KernelGlobals *kg,
   if (sd->flag & SD_EMISSION) {
     float3 emission = indirect_primitive_emission(
         kg, sd, sd->ray_length, state->flag, state->ray_pdf);
-    path_radiance_accum_emission(L, state, throughput, emission);
+    path_radiance_accum_emission(kg, L, state, throughput, emission);
   }
 #endif /* __EMISSION__ */
 
@@ -369,7 +366,7 @@ ccl_device_noinline
     light_ray.dD = differential3_zero();
 
     if (!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &ao_shadow)) {
-      path_radiance_accum_ao(L, state, throughput, ao_alpha, ao_bsdf, ao_shadow);
+      path_radiance_accum_ao(kg, L, state, throughput, ao_alpha, ao_bsdf, ao_shadow);
     }
     else {
       path_radiance_accum_total_ao(L, state, throughput, ao_bsdf);
@@ -675,7 +672,7 @@ ccl_device void kernel_path_trace(
   float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
 
   PathRadiance L;
-  path_radiance_init(&L, kernel_data.film.use_light_pass);
+  path_radiance_init(kg, &L);
 
   ShaderDataTinyStorage emission_sd_storage;
   ShaderData *emission_sd = AS_SHADER_DATA(&emission_sd_storage);
index 39309379f0cb59f50339c06dbdf3de668aa28e93..f75e4ab4c978b255ded0b5051bc68117f4b428f5 100644 (file)
@@ -55,7 +55,7 @@ ccl_device_inline void kernel_branched_path_ao(KernelGlobals *kg,
 
       if (!shadow_blocked(kg, sd, emission_sd, state, &light_ray, &ao_shadow)) {
         path_radiance_accum_ao(
-            L, state, throughput * num_samples_inv, ao_alpha, ao_bsdf, ao_shadow);
+            kg, L, state, throughput * num_samples_inv, ao_alpha, ao_bsdf, ao_shadow);
       }
       else {
         path_radiance_accum_total_ao(L, state, throughput * num_samples_inv, ao_bsdf);
@@ -146,7 +146,7 @@ ccl_device_forceinline void kernel_branched_path_volume(KernelGlobals *kg,
 
     /* emission and transmittance */
     if (volume_segment.closure_flag & SD_EMISSION)
-      path_radiance_accum_emission(L, state, *throughput, volume_segment.accum_emission);
+      path_radiance_accum_emission(kg, L, state, *throughput, volume_segment.accum_emission);
     *throughput *= volume_segment.accum_transmittance;
 
     /* free cached steps */
@@ -376,7 +376,7 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg,
   /* initialize */
   float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
 
-  path_radiance_init(L, kernel_data.film.use_light_pass);
+  path_radiance_init(kg, L);
 
   /* shader data memory used for both volumes and surfaces, saves stack space */
   ShaderData sd;
index a32690d51eb551024a16a0f70291ec3b1fe82fa4..ba48c0bdfc4a5fcb30d1307760d6e0995e2d72d3 100644 (file)
@@ -121,8 +121,14 @@ ccl_device_noinline_cpu void kernel_branched_path_surface_connect_light(
       if (has_emission) {
         if (!blocked) {
           /* accumulate */
-          path_radiance_accum_light(
-              L, state, throughput * num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
+          path_radiance_accum_light(kg,
+                                    L,
+                                    state,
+                                    throughput * num_samples_inv,
+                                    &L_light,
+                                    shadow,
+                                    num_samples_inv,
+                                    is_lamp);
         }
         else {
           path_radiance_accum_total_light(L, state, throughput * num_samples_inv, &L_light);
@@ -250,7 +256,7 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg,
   if (has_emission) {
     if (!blocked) {
       /* accumulate */
-      path_radiance_accum_light(L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
+      path_radiance_accum_light(kg, L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
     }
     else {
       path_radiance_accum_total_light(L, state, throughput, &L_light);
index db10629ee9f1a9d4d95c29e2aaa95d1834de49c6..a787910e65c4d61b23cf8adcedd85a64d759ee90 100644 (file)
@@ -57,7 +57,7 @@ ccl_device_inline void kernel_path_volume_connect_light(KernelGlobals *kg,
 
   if (has_emission && !blocked) {
     /* accumulate */
-    path_radiance_accum_light(L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
+    path_radiance_accum_light(kg, L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
   }
 #  endif /* __EMISSION__ */
 }
@@ -247,7 +247,7 @@ ccl_device void kernel_branched_path_volume_connect_light(KernelGlobals *kg,
       if (has_emission && !blocked) {
         /* accumulate */
         path_radiance_accum_light(
-            L, state, tp * num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
+            kg, L, state, tp * num_samples_inv, &L_light, shadow, num_samples_inv, is_lamp);
       }
     }
   }
index 4ddcbec0fef743191fa69e07f0792fea4a47a76a..f443bb88463c99e13350793ca1c981ea5df5f8fc 100644 (file)
@@ -504,7 +504,7 @@ kernel_volume_integrate_homogeneous(KernelGlobals *kg,
     float3 transmittance = volume_color_transmittance(coeff.sigma_t, ray->t);
     float3 emission = kernel_volume_emission_integrate(
         &coeff, closure_flag, transmittance, ray->t);
-    path_radiance_accum_emission(L, state, *throughput, emission);
+    path_radiance_accum_emission(kg, L, state, *throughput, emission);
   }
 
   /* modify throughput */
@@ -629,7 +629,7 @@ kernel_volume_integrate_heterogeneous_distance(KernelGlobals *kg,
       if (L && (closure_flag & SD_EMISSION)) {
         float3 emission = kernel_volume_emission_integrate(
             &coeff, closure_flag, transmittance, dt);
-        path_radiance_accum_emission(L, state, tp, emission);
+        path_radiance_accum_emission(kg, L, state, tp, emission);
       }
 
       /* modify throughput */
index e08d87ab618c69b29f04385e9471c9c5dc219f69..bfcd21baac452f8536e637d362ea433d7679018b 100644 (file)
@@ -106,7 +106,7 @@ ccl_device_inline bool kernel_split_branched_indirect_start_shared(KernelGlobals
   PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
   PathRadiance *inactive_L = &kernel_split_state.path_radiance[inactive_ray];
 
-  path_radiance_init(inactive_L, kernel_data.film.use_light_pass);
+  path_radiance_init(kg, inactive_L);
   path_radiance_copy_indirect(inactive_L, L);
 
   ray_state[inactive_ray] = RAY_REGENERATED;
index e37be5b405edd276afce58e9740fc3307f84c1c2..dba1768f03f99bc82b81e9fae611d1dbe46e0519 100644 (file)
@@ -135,7 +135,7 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg,
            * These rays proceed with path-iteration.
            */
           *throughput = make_float3(1.0f, 1.0f, 1.0f);
-          path_radiance_init(L, kernel_data.film.use_light_pass);
+          path_radiance_init(kg, L);
           path_state_init(kg,
                           AS_SHADER_DATA(&kernel_split_state.sd_DL_shadow[ray_index]),
                           state,
index 3faa3208341e5bc9d22386f2e771efb63858b508..82b0f583d8d76ef26d525962d7bf716b4b724bf8 100644 (file)
@@ -59,8 +59,7 @@ ccl_device void kernel_path_init(KernelGlobals *kg)
      * These rays proceed with path-iteration.
      */
     kernel_split_state.throughput[ray_index] = make_float3(1.0f, 1.0f, 1.0f);
-    path_radiance_init(&kernel_split_state.path_radiance[ray_index],
-                       kernel_data.film.use_light_pass);
+    path_radiance_init(kg, &kernel_split_state.path_radiance[ray_index]);
     path_state_init(kg,
                     AS_SHADER_DATA(&kernel_split_state.sd_DL_shadow[ray_index]),
                     &kernel_split_state.path_state[ray_index],
index 82990ce9fae84fdb6cf69ab29517a08209015df1..5e46d300bca22aa8aa01908f1e90f7a9d57230b1 100644 (file)
@@ -87,7 +87,7 @@ ccl_device void kernel_shadow_blocked_dl(KernelGlobals *kg)
 
     if (!shadow_blocked(kg, sd, emission_sd, state, &ray, &shadow)) {
       /* accumulate */
-      path_radiance_accum_light(L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
+      path_radiance_accum_light(kg, L, state, throughput, &L_light, shadow, 1.0f, is_lamp);
     }
     else {
       path_radiance_accum_total_light(L, state, throughput, &L_light);
index 379b0e6c214dbb112f07ca0f06969f8ebdac16bb..3cd7936ae45eab9b3e774208e7272ad80dac2140 100644 (file)
@@ -287,8 +287,6 @@ NODE_DEFINE(Film)
   SOCKET_FLOAT(mist_depth, "Mist Depth", 100.0f);
   SOCKET_FLOAT(mist_falloff, "Mist Falloff", 1.0f);
 
-  SOCKET_BOOLEAN(use_sample_clamp, "Use Sample Clamp", false);
-
   SOCKET_BOOLEAN(denoising_data_pass, "Generate Denoising Data Pass", false);
   SOCKET_BOOLEAN(denoising_clean_pass, "Generate Denoising Clean Pass", false);
   SOCKET_BOOLEAN(denoising_prefiltered_pass, "Generate Denoising Prefiltered Pass", false);
@@ -331,7 +329,7 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
 
   kfilm->light_pass_flag = 0;
   kfilm->pass_stride = 0;
-  kfilm->use_light_pass = use_light_visibility || use_sample_clamp;
+  kfilm->use_light_pass = use_light_visibility;
 
   bool have_cryptomatte = false, have_aov_color = false, have_aov_value = false;
 
index 48673af01143356929d33d7c099aede55228e479..95e54cb54d8f948f854324662264546643b3b2fd 100644 (file)
@@ -78,7 +78,6 @@ class Film : public Node {
   float mist_falloff;
 
   bool use_light_visibility;
-  bool use_sample_clamp;
   CryptomatteType cryptomatte_passes;
   int cryptomatte_depth;
 
index b41b0b7b2602848b6c52bd1ffc97aab0a11089fc..530c32106b7b70f8b042996e2f9020292d739b62 100644 (file)
@@ -209,13 +209,6 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
 
   dscene->sobol_directions.copy_to_device();
 
-  /* Clamping. */
-  bool use_sample_clamp = (sample_clamp_direct != 0.0f || sample_clamp_indirect != 0.0f);
-  if (use_sample_clamp != scene->film->use_sample_clamp) {
-    scene->film->use_sample_clamp = use_sample_clamp;
-    scene->film->tag_update(scene);
-  }
-
   need_update = false;
 }