Commit: 10f0e003a95a9d28be162605d7985c4d4620f6c0
Author: Brecht Van Lommel
Date:   Mon Apr 6 22:37:50 2020 +0200
Branches: master
https://developer.blender.org/rB10f0e003a95a9d28be162605d7985c4d4620f6c0

Fix T74572: adaptive sampling not scaling AOVs correctly

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

M       intern/cycles/kernel/kernel_adaptive_sampling.h
M       intern/cycles/kernel/kernel_types.h
M       intern/cycles/render/film.cpp

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

diff --git a/intern/cycles/kernel/kernel_adaptive_sampling.h 
b/intern/cycles/kernel/kernel_adaptive_sampling.h
index 047fe8c92ec..ee4d1507ef1 100644
--- a/intern/cycles/kernel/kernel_adaptive_sampling.h
+++ b/intern/cycles/kernel/kernel_adaptive_sampling.h
@@ -150,6 +150,7 @@ ccl_device void kernel_adaptive_post_adjust(KernelGlobals 
*kg,
   }
 #endif /* __DENOISING_FEATURES__ */
 
+  /* Cryptomatte. */
   if (kernel_data.film.cryptomatte_passes) {
     int num_slots = 0;
     num_slots += (kernel_data.film.cryptomatte_passes & CRYPT_OBJECT) ? 1 : 0;
@@ -162,6 +163,14 @@ ccl_device void kernel_adaptive_post_adjust(KernelGlobals 
*kg,
       id_buffer[slot].y *= sample_multiplier;
     }
   }
+
+  /* AOVs. */
+  for (int i = 0; i < kernel_data.film.pass_aov_value_num; i++) {
+    *(buffer + kernel_data.film.pass_aov_value + i) *= sample_multiplier;
+  }
+  for (int i = 0; i < kernel_data.film.pass_aov_color_num; i++) {
+    *((ccl_global float4 *)(buffer + kernel_data.film.pass_aov_color) + i) *= 
sample_multiplier;
+  }
 }
 
 /* This is a simple box filter in two passes.
diff --git a/intern/cycles/kernel/kernel_types.h 
b/intern/cycles/kernel/kernel_types.h
index b6d319311a1..44c936da626 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -1242,7 +1242,9 @@ typedef struct KernelFilm {
 
   int pass_aov_color;
   int pass_aov_value;
-  int pad1;
+  int pass_aov_color_num;
+  int pass_aov_value_num;
+  int pad1, pad2, pad3;
 
   /* XYZ to rendering color space transform. float4 instead of float3 to
    * ensure consistent padding/alignment across devices. */
@@ -1265,7 +1267,7 @@ typedef struct KernelFilm {
   int use_display_exposure;
   int use_display_pass_alpha;
 
-  int pad3, pad4, pad5;
+  int pad4, pad5, pad6;
 } KernelFilm;
 static_assert_align(KernelFilm, 16);
 
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index baf02901123..f28c943ea6c 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -362,8 +362,10 @@ 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;
+  kfilm->pass_aov_value_num = 0;
+  kfilm->pass_aov_color_num = 0;
 
-  bool have_cryptomatte = false, have_aov_color = false, have_aov_value = 
false;
+  bool have_cryptomatte = false;
 
   for (size_t i = 0; i < passes.size(); i++) {
     Pass &pass = passes[i];
@@ -498,16 +500,16 @@ void Film::device_update(Device *device, DeviceScene 
*dscene, Scene *scene)
         kfilm->pass_sample_count = kfilm->pass_stride;
         break;
       case PASS_AOV_COLOR:
-        if (!have_aov_color) {
+        if (kfilm->pass_aov_value_num == 0) {
           kfilm->pass_aov_color = kfilm->pass_stride;
-          have_aov_color = true;
         }
+        kfilm->pass_aov_value_num++;
         break;
       case PASS_AOV_VALUE:
-        if (!have_aov_value) {
+        if (kfilm->pass_aov_color_num == 0) {
           kfilm->pass_aov_value = kfilm->pass_stride;
-          have_aov_value = true;
         }
+        kfilm->pass_aov_color_num++;
         break;
       default:
         assert(false);

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to