Fix T74063: Cycles light pass viewport display wrong with saturated colors
authorBrecht Van Lommel <brecht@blender.org>
Tue, 25 Feb 2020 18:51:20 +0000 (19:51 +0100)
committerBrecht Van Lommel <brecht@blender.org>
Tue, 25 Feb 2020 18:52:18 +0000 (19:52 +0100)
intern/cycles/kernel/kernel_film.h

index fc3a6152b79f5caf81bfbf6d395c7dbc31e512d9..3829426f2612f0a325b9412f52c2dad56009dc8b 100644 (file)
@@ -40,15 +40,9 @@ ccl_device float4 film_get_pass_result(KernelGlobals *kg,
     if (display_divide_pass_stride != -1) {
       ccl_global float4 *divide_in = (ccl_global float4 *)(buffer + display_divide_pass_stride +
                                                            index * kernel_data.film.pass_stride);
-      if (divide_in->x != 0.0f) {
-        pass_result.x /= divide_in->x;
-      }
-      if (divide_in->y != 0.0f) {
-        pass_result.y /= divide_in->y;
-      }
-      if (divide_in->z != 0.0f) {
-        pass_result.z /= divide_in->z;
-      }
+      float3 divided = safe_divide_even_color(float4_to_float3(pass_result),
+                                              float4_to_float3(*divide_in));
+      pass_result = make_float4(divided.x, divided.y, divided.z, pass_result.w);
     }
 
     if (kernel_data.film.use_display_exposure) {