[Bf-blender-cvs] [50069fb2a11] blender-v3.3-release: Fix T100708: Cycles bake of diffuse/glossy color not outputting alpha

Brecht Van Lommel noreply at git.blender.org
Wed Sep 21 14:27:08 CEST 2022


Commit: 50069fb2a11eb79c860be8c1d34817cadeafe04e
Author: Brecht Van Lommel
Date:   Wed Aug 31 20:09:12 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rB50069fb2a11eb79c860be8c1d34817cadeafe04e

Fix T100708: Cycles bake of diffuse/glossy color not outputting alpha

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

M	intern/cycles/integrator/pass_accessor.cpp
M	intern/cycles/kernel/film/read.h
M	intern/cycles/kernel/integrator/init_from_bake.h

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

diff --git a/intern/cycles/integrator/pass_accessor.cpp b/intern/cycles/integrator/pass_accessor.cpp
index 05318b7545b..ab056e953c2 100644
--- a/intern/cycles/integrator/pass_accessor.cpp
+++ b/intern/cycles/integrator/pass_accessor.cpp
@@ -191,6 +191,12 @@ bool PassAccessor::get_render_tile_pixels(const RenderBuffers *render_buffers,
        * had the computation done. */
       if (pass_info.num_components == 3) {
         get_pass_float3(render_buffers, buffer_params, destination);
+
+        /* Use alpha for colors passes. */
+        if (type == PASS_DIFFUSE_COLOR || type == PASS_GLOSSY_COLOR ||
+            type == PASS_TRANSMISSION_COLOR) {
+          num_written_components = destination.num_components;
+        }
       }
       else if (pass_info.num_components == 4) {
         if (destination.num_components == 3) {
diff --git a/intern/cycles/kernel/film/read.h b/intern/cycles/kernel/film/read.h
index a0236909f4b..995c20a0053 100644
--- a/intern/cycles/kernel/film/read.h
+++ b/intern/cycles/kernel/film/read.h
@@ -235,6 +235,21 @@ ccl_device_inline void film_get_pass_pixel_float3(ccl_global const KernelFilmCon
   pixel[0] = f.x;
   pixel[1] = f.y;
   pixel[2] = f.z;
+
+  /* Optional alpha channel. */
+  if (kfilm_convert->num_components >= 4) {
+    if (kfilm_convert->pass_combined != PASS_UNUSED) {
+      float scale, scale_exposure;
+      film_get_scale_and_scale_exposure(kfilm_convert, buffer, &scale, &scale_exposure);
+
+      ccl_global const float *in_combined = buffer + kfilm_convert->pass_combined;
+      const float alpha = in_combined[3] * scale;
+      pixel[3] = film_transparency_to_alpha(alpha);
+    }
+    else {
+      pixel[3] = 1.0f;
+    }
+  }
 }
 
 /* --------------------------------------------------------------------
diff --git a/intern/cycles/kernel/integrator/init_from_bake.h b/intern/cycles/kernel/integrator/init_from_bake.h
index dd26215bcd2..c77fc2540c1 100644
--- a/intern/cycles/kernel/integrator/init_from_bake.h
+++ b/intern/cycles/kernel/integrator/init_from_bake.h
@@ -113,7 +113,7 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg,
   if (prim == -1) {
     /* Accumulate transparency for empty pixels. */
     kernel_accum_transparent(kg, state, 0, 1.0f, buffer);
-    return false;
+    return true;
   }
 
   prim += kernel_data.bake.tri_offset;



More information about the Bf-blender-cvs mailing list