diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-02-12 13:29:50 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-02-12 13:35:05 +0300 |
commit | 26481eabe1e66da2a322190f15ad600d9d69bbee (patch) | |
tree | 15a56363f559558847e2ea7becad623d6d4d550f /intern/cycles/blender/addon | |
parent | 837b5743ced83c5dfe724a8285eee504f623dbfb (diff) |
Cycles: Use Blender Settings For AOV
This patch will share the AOV settings between Cycles and Eevee.
It enable using the AOV name conflict detection of Blender. This
means that unlike how Cycles used to work it isn't possible to add an
AOV with a similar name. Conflicts with internal render pass names will
be indicated with an Warning icon.
Reviewed By: Brecht van Lommel
Differential Revision: https://developer.blender.org/D9774
Diffstat (limited to 'intern/cycles/blender/addon')
-rw-r--r-- | intern/cycles/blender/addon/engine.py | 21 | ||||
-rw-r--r-- | intern/cycles/blender/addon/operators.py | 32 | ||||
-rw-r--r-- | intern/cycles/blender/addon/properties.py | 38 | ||||
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 43 | ||||
-rw-r--r-- | intern/cycles/blender/addon/version_update.py | 14 |
5 files changed, 17 insertions, 131 deletions
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index 179eea6461c..7595261f523 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -301,7 +301,7 @@ def list_render_passes(scene, srl): yield ("Denoising Clean", "RGB", 'COLOR') # Custom AOV passes. - for aov in crl.aovs: + for aov in srl.aovs: if aov.type == 'VALUE': yield (aov.name, "X", 'VALUE') else: @@ -309,22 +309,5 @@ def list_render_passes(scene, srl): def register_passes(engine, scene, view_layer): - # Detect duplicate render pass names, first one wins. - listed = set() for name, channelids, channeltype in list_render_passes(scene, view_layer): - if name not in listed: - engine.register_pass(scene, view_layer, name, len(channelids), channelids, channeltype) - listed.add(name) - - -def detect_conflicting_passes(scene, view_layer): - # Detect conflicting render pass names for UI. - counter = {} - for name, _, _ in list_render_passes(scene, view_layer): - counter[name] = counter.get(name, 0) + 1 - - for aov in view_layer.cycles.aovs: - if counter[aov.name] > 1: - aov.conflict = "Conflicts with another render pass with the same name" - else: - aov.conflict = "" + engine.register_pass(scene, view_layer, name, len(channelids), channelids, channeltype) diff --git a/intern/cycles/blender/addon/operators.py b/intern/cycles/blender/addon/operators.py index 2045f6ab780..087e5b666a5 100644 --- a/intern/cycles/blender/addon/operators.py +++ b/intern/cycles/blender/addon/operators.py @@ -44,36 +44,6 @@ class CYCLES_OT_use_shading_nodes(Operator): return {'FINISHED'} -class CYCLES_OT_add_aov(bpy.types.Operator): - """Add an AOV pass""" - bl_idname = "cycles.add_aov" - bl_label = "Add AOV" - - def execute(self, context): - view_layer = context.view_layer - cycles_view_layer = view_layer.cycles - - cycles_view_layer.aovs.add() - - view_layer.update_render_passes() - return {'FINISHED'} - - -class CYCLES_OT_remove_aov(bpy.types.Operator): - """Remove an AOV pass""" - bl_idname = "cycles.remove_aov" - bl_label = "Remove AOV" - - def execute(self, context): - view_layer = context.view_layer - cycles_view_layer = view_layer.cycles - - cycles_view_layer.aovs.remove(cycles_view_layer.active_aov) - - view_layer.update_render_passes() - return {'FINISHED'} - - class CYCLES_OT_denoise_animation(Operator): "Denoise rendered animation sequence using current scene and view " \ "layer settings. Requires denoising data passes and output to " \ @@ -197,8 +167,6 @@ class CYCLES_OT_merge_images(Operator): classes = ( CYCLES_OT_use_shading_nodes, - CYCLES_OT_add_aov, - CYCLES_OT_remove_aov, CYCLES_OT_denoise_animation, CYCLES_OT_merge_images ) diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 2f204b2c658..dd218d93d32 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -178,11 +178,6 @@ enum_view3d_shading_render_pass = ( ('MIST', "Mist", "Show the Mist render pass", 32), ) -enum_aov_types = ( - ('VALUE', "Value", "Write a Value pass", 0), - ('COLOR', "Color", "Write a Color pass", 1), -) - def enum_openimagedenoise_denoiser(self, context): import _cycles @@ -229,7 +224,6 @@ def update_render_passes(self, context): scene = context.scene view_layer = context.view_layer view_layer.update_render_passes() - engine.detect_conflicting_passes(scene, view_layer) class CyclesRenderSettings(bpy.types.PropertyGroup): @@ -1311,27 +1305,6 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup): del bpy.types.Scene.cycles_curves -class CyclesAOVPass(bpy.types.PropertyGroup): - name: StringProperty( - name="Name", - description="Name of the pass, to use in the AOV Output shader node", - update=update_render_passes, - default="AOV" - ) - type: EnumProperty( - name="Type", - description="Pass data type", - update=update_render_passes, - items=enum_aov_types, - default='COLOR' - ) - conflict: StringProperty( - name="Conflict", - description="If there is a conflict with another render passes, message explaining why", - default="" - ) - - class CyclesRenderLayerSettings(bpy.types.PropertyGroup): pass_debug_bvh_traversed_nodes: BoolProperty( @@ -1470,15 +1443,6 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup): default='RGB_ALBEDO_NORMAL', ) - aovs: CollectionProperty( - type=CyclesAOVPass, - description="Custom render passes that can be output by shader nodes", - ) - active_aov: IntProperty( - default=0, - min=0 - ) - @classmethod def register(cls): bpy.types.ViewLayer.cycles = PointerProperty( @@ -1665,7 +1629,6 @@ def register(): bpy.utils.register_class(CyclesCurveRenderSettings) bpy.utils.register_class(CyclesDeviceSettings) bpy.utils.register_class(CyclesPreferences) - bpy.utils.register_class(CyclesAOVPass) bpy.utils.register_class(CyclesRenderLayerSettings) bpy.utils.register_class(CyclesView3DShadingSettings) @@ -1687,6 +1650,5 @@ def unregister(): bpy.utils.unregister_class(CyclesCurveRenderSettings) bpy.utils.unregister_class(CyclesDeviceSettings) bpy.utils.unregister_class(CyclesPreferences) - bpy.utils.unregister_class(CyclesAOVPass) bpy.utils.unregister_class(CyclesRenderLayerSettings) bpy.utils.unregister_class(CyclesView3DShadingSettings) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index aa009c15b10..53676832243 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -23,7 +23,7 @@ from bl_ui.utils import PresetPanel from bpy.types import Panel from bl_ui.properties_grease_pencil_common import GreasePencilSimplifyPanel -from bl_ui.properties_view_layer import ViewLayerCryptomattePanel +from bl_ui.properties_view_layer import ViewLayerCryptomattePanel, ViewLayerAOVPanel class CYCLES_PT_sampling_presets(PresetPanel, Panel): @@ -915,49 +915,11 @@ class CYCLES_RENDER_PT_passes_debug(CyclesButtonsPanel, Panel): layout.prop(cycles_view_layer, "pass_debug_ray_bounces") -class CYCLES_RENDER_UL_aov(bpy.types.UIList): - def draw_item(self, context, layout, data, item, icon, active_data, active_propname): - row = layout.row() - split = row.split(factor=0.65) - icon = 'ERROR' if item.conflict else 'NONE' - split.row().prop(item, "name", text="", icon=icon, emboss=False) - split.row().prop(item, "type", text="", emboss=False) - - -class CYCLES_RENDER_PT_passes_aov(CyclesButtonsPanel, Panel): +class CYCLES_RENDER_PT_passes_aov(CyclesButtonsPanel, ViewLayerAOVPanel): bl_label = "Shader AOV" bl_context = "view_layer" bl_parent_id = "CYCLES_RENDER_PT_passes" - def draw(self, context): - layout = self.layout - layout.use_property_split = True - layout.use_property_decorate = False - - cycles_view_layer = context.view_layer.cycles - - row = layout.row() - col = row.column() - col.template_list( - "CYCLES_RENDER_UL_aov", - "aovs", - cycles_view_layer, - "aovs", - cycles_view_layer, - "active_aov", - rows=2, - ) - - col = row.column() - sub = col.column(align=True) - sub.operator("cycles.add_aov", icon='ADD', text="") - sub.operator("cycles.remove_aov", icon='REMOVE', text="") - - if cycles_view_layer.active_aov < len(cycles_view_layer.aovs): - active_aov = cycles_view_layer.aovs[cycles_view_layer.active_aov] - if active_aov.conflict: - layout.label(text=active_aov.conflict, icon='ERROR') - class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel): bl_label = "Denoising" @@ -2300,7 +2262,6 @@ classes = ( CYCLES_RENDER_PT_passes_light, CYCLES_RENDER_PT_passes_crypto, CYCLES_RENDER_PT_passes_debug, - CYCLES_RENDER_UL_aov, CYCLES_RENDER_PT_passes_aov, CYCLES_RENDER_PT_filter, CYCLES_RENDER_PT_override, diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py index 5dae88d60c7..2c5df9a9af3 100644 --- a/intern/cycles/blender/addon/version_update.py +++ b/intern/cycles/blender/addon/version_update.py @@ -108,7 +108,7 @@ def do_versions(self): library_versions.setdefault(library.version, []).append(library) # Do versioning per library, since they might have different versions. - max_need_versioning = (2, 92, 4) + max_need_versioning = (2, 92, 14) for version, libraries in library_versions.items(): if version > max_need_versioning: continue @@ -204,6 +204,18 @@ def do_versions(self): view_layer.pass_cryptomatte_depth = cview_layer.get("pass_crypto_depth", 6) view_layer.use_pass_cryptomatte_accurate = cview_layer.get("pass_crypto_accurate", True) + if version <= (2, 92, 14): + if scene.render.engine == 'CYCLES': + for view_layer in scene.view_layers: + cview_layer = view_layer.cycles + for caov in cview_layer.get("aovs", []): + aov_name = caov.get("name", "AOV") + if aov_name in view_layer.aovs: + continue + baov = view_layer.aovs.add() + baov.name = caov.get("name", "AOV") + baov.type = "COLOR" if caov.get("type", 1) == 1 else "VALUE" + # Lamps for light in bpy.data.lights: if light.library not in libraries: |