Cycles: add object level holdout property, to replace Z mask layer.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 18 Nov 2017 05:06:27 +0000 (06:06 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 23 Nov 2017 23:12:48 +0000 (00:12 +0100)
intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_object.cpp

index 3ce8852abc2868978d481022b7754d8fd647d79b..43f04bdff7a767392cc261dd0c565932d95ccb6a 100644 (file)
@@ -1081,6 +1081,15 @@ class CyclesObjectSettings(bpy.types.PropertyGroup):
                 default=False,
                 )
 
+        cls.is_holdout = BoolProperty(
+                name="Holdout",
+                description="Render objects as a holdout or matte, creating a "
+                            "hole in the image with zero alpha, to fill out in "
+                            "compositing with real footange or another render",
+                default=False,
+                )
+
+
     @classmethod
     def unregister(cls):
         del bpy.types.Object.cycles
index 79ed01191d8fca3400986700b839c1945db2a06d..b3b50fd6181da0a7b3121bef5a1f587f0e2db9e8 100644 (file)
@@ -841,7 +841,9 @@ class CYCLES_OBJECT_PT_cycles_settings(CyclesButtonsPanel, Panel):
         if ob.type != 'LAMP':
             flow.prop(visibility, "shadow")
 
-        layout.prop(cob, "is_shadow_catcher")
+        row = layout.row()
+        row.prop(cob, "is_shadow_catcher")
+        row.prop(cob, "is_holdout")
 
         col = layout.column()
         col.label(text="Performance:")
index d92105850444626e77d1ce4802a548a422cffbd2..0c29c606df87ea284a559a90b1ba3150e9300395 100644 (file)
@@ -314,7 +314,9 @@ Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter,
        }
 
        /* Visibility flags for both parent and child. */
-       bool use_holdout = (layer_flag & view_layer.holdout_layer) != 0;
+       PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
+       bool use_holdout = (layer_flag & view_layer.holdout_layer) != 0 ||
+                          get_boolean(cobject, "is_holdout");
        uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY;
 
        if(b_parent.ptr.data != b_ob.ptr.data) {
@@ -393,7 +395,6 @@ Object *BlenderSync::sync_object(BL::Depsgraph::duplis_iterator& b_dupli_iter,
                object_updated = true;
        }
 
-       PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
        bool is_shadow_catcher = get_boolean(cobject, "is_shadow_catcher");
        if(is_shadow_catcher != object->is_shadow_catcher) {
                object->is_shadow_catcher = is_shadow_catcher;