From ca64bd0aacdaa9fcf75d693321d4d73c4a6a991a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 4 Aug 2021 19:43:40 +0200 Subject: Render: move Cycles visibility, holdout and shadow catcher properties to Blender The immediate reason for this is that we want to be able to initialize them to different defaults for light objects, which is hard with Python properties. But in general it is useful to be able to share these with other renderers. As a side effect, Eevee now supports a per-object holdout instead of only per-collection. Differential Revision: https://developer.blender.org/D12133 --- intern/cycles/blender/addon/properties.py | 21 --------------------- intern/cycles/blender/addon/ui.py | 19 ++++++++----------- intern/cycles/blender/blender_object.cpp | 6 ++---- intern/cycles/blender/blender_util.h | 13 ++++++------- 4 files changed, 16 insertions(+), 43 deletions(-) (limited to 'intern') diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 70efb1054a2..124223635d1 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -1164,12 +1164,6 @@ class CyclesVisibilitySettings(bpy.types.PropertyGroup): @classmethod def register(cls): - bpy.types.Object.cycles_visibility = PointerProperty( - name="Cycles Visibility Settings", - description="Cycles visibility settings", - type=cls, - ) - bpy.types.World.cycles_visibility = PointerProperty( name="Cycles Visibility Settings", description="Cycles visibility settings", @@ -1178,7 +1172,6 @@ class CyclesVisibilitySettings(bpy.types.PropertyGroup): @classmethod def unregister(cls): - del bpy.types.Object.cycles_visibility del bpy.types.World.cycles_visibility @@ -1276,20 +1269,6 @@ class CyclesObjectSettings(bpy.types.PropertyGroup): subtype='DISTANCE', ) - is_shadow_catcher: BoolProperty( - name="Shadow Catcher", - description="Only render shadows on this object, for compositing renders into real footage", - default=False, - ) - - 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 footage or another render", - default=False, - ) - @classmethod def register(cls): bpy.types.Object.cycles = PointerProperty( diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index e804f697571..47f7b4c6d73 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -1270,10 +1270,9 @@ class CYCLES_OBJECT_PT_visibility(CyclesButtonsPanel, Panel): col.prop(ob, "hide_render", text="Renders", invert_checkbox=True, toggle=False) if has_geometry_visibility(ob): - cob = ob.cycles col = layout.column(heading="Mask") - col.prop(cob, "is_shadow_catcher") - col.prop(cob, "is_holdout") + col.prop(ob, "is_shadow_catcher") + col.prop(ob, "is_holdout") class CYCLES_OBJECT_PT_visibility_ray_visibility(CyclesButtonsPanel, Panel): @@ -1293,19 +1292,17 @@ class CYCLES_OBJECT_PT_visibility_ray_visibility(CyclesButtonsPanel, Panel): scene = context.scene ob = context.object - cob = ob.cycles - visibility = ob.cycles_visibility col = layout.column() - col.prop(visibility, "camera") - col.prop(visibility, "diffuse") - col.prop(visibility, "glossy") - col.prop(visibility, "transmission") - col.prop(visibility, "scatter") + col.prop(ob, "visible_camera", text="Camera") + col.prop(ob, "visible_diffuse", text="Diffuse") + col.prop(ob, "visible_glossy", text="Glossy") + col.prop(ob, "visible_transmission", text="Transmission") + col.prop(ob, "visible_volume_scatter", text="Volume Scatter") if ob.type != 'LIGHT': sub = col.column() - sub.prop(visibility, "shadow") + sub.prop(ob, "visible_shadow", text="Shadow") class CYCLES_OBJECT_PT_visibility_culling(CyclesButtonsPanel, Panel): diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index 65b5ac2c58f..4711e0cbe76 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -199,8 +199,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph, /* Visibility flags for both parent and child. */ PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles"); - bool use_holdout = get_boolean(cobject, "is_holdout") || - b_parent.holdout_get(PointerRNA_NULL, b_view_layer); + bool use_holdout = b_parent.holdout_get(PointerRNA_NULL, b_view_layer); uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY; if (b_parent.ptr.data != b_ob.ptr.data) { @@ -287,8 +286,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph, object->set_visibility(visibility); - bool is_shadow_catcher = get_boolean(cobject, "is_shadow_catcher"); - object->set_is_shadow_catcher(is_shadow_catcher); + object->set_is_shadow_catcher(b_ob.is_shadow_catcher()); float shadow_terminator_shading_offset = get_float(cobject, "shadow_terminator_offset"); object->set_shadow_terminator_shading_offset(shadow_terminator_shading_offset); diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 43dbb4105df..2b2188b023d 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -596,15 +596,14 @@ static inline Mesh::SubdivisionType object_subdivision_type(BL::Object &b_ob, static inline uint object_ray_visibility(BL::Object &b_ob) { - PointerRNA cvisibility = RNA_pointer_get(&b_ob.ptr, "cycles_visibility"); uint flag = 0; - flag |= get_boolean(cvisibility, "camera") ? PATH_RAY_CAMERA : 0; - flag |= get_boolean(cvisibility, "diffuse") ? PATH_RAY_DIFFUSE : 0; - flag |= get_boolean(cvisibility, "glossy") ? PATH_RAY_GLOSSY : 0; - flag |= get_boolean(cvisibility, "transmission") ? PATH_RAY_TRANSMIT : 0; - flag |= get_boolean(cvisibility, "shadow") ? PATH_RAY_SHADOW : 0; - flag |= get_boolean(cvisibility, "scatter") ? PATH_RAY_VOLUME_SCATTER : 0; + flag |= b_ob.visible_camera() ? PATH_RAY_CAMERA : 0; + flag |= b_ob.visible_diffuse() ? PATH_RAY_DIFFUSE : 0; + flag |= b_ob.visible_glossy() ? PATH_RAY_GLOSSY : 0; + flag |= b_ob.visible_transmission() ? PATH_RAY_TRANSMIT : 0; + flag |= b_ob.visible_shadow() ? PATH_RAY_SHADOW : 0; + flag |= b_ob.visible_volume_scatter() ? PATH_RAY_VOLUME_SCATTER : 0; return flag; } -- cgit v1.2.3