From ea0561e14ea4974342d47b500f7f1cdd0bddbbad Mon Sep 17 00:00:00 2001 From: pullusb Date: Mon, 9 Sep 2024 14:38:16 +0200 Subject: [PATCH] Add more default prefix for mask layer exclusion 1.8.3 - changed: for layer with 0 opacity, do not send to render and keep opacity - removed: `GP` prefix exclusion to send GP to render - added: more default prefix exclusion for _layer to render_ and _skip opacity reset_ (`MASK, mask, MSK, msk`) --- CHANGELOG.md | 7 +++++++ OP_auto_build.py | 12 ++++++------ OP_setup_layers.py | 16 ++++++++++------ __init__.py | 2 +- gen_vlayer.py | 5 +++-- 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7ff1b6..170b7b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,13 @@ Activate / deactivate layer opacity according to prefix Activate / deactivate all masks using MA layers --> +1.8.3 + +- changed: for layer with 0 opacity, do not send to render and keep opacity +- removed: `GP` prefix exclusion to send GP to render +- added: more default prefix exclusion for _layer to render_ and _skip opacity reset_ (`MASK, mask, MSK, msk`) +- added: option to restore layer state from json (commit by Christophe.S) + 1.8.2 - added: `Reset Layer State` (Check layer) in Autobuild diff --git a/OP_auto_build.py b/OP_auto_build.py index 206e0e0..377bb5f 100644 --- a/OP_auto_build.py +++ b/OP_auto_build.py @@ -77,7 +77,7 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator): description='Set single user on all objects GP data') excluded_prefix : StringProperty( - name='Excluded Layer By Prefix', default='GP, RG, PO, MA', + name='Excluded Layer By Prefix', default='RG, PO, MA, MASK, mask, MSK, msk', description='Exclude layer to send to render by prefix (comma separated list)') clean_name_and_visibility : BoolProperty(name='Clean Name And Visibility', default=True, @@ -196,7 +196,7 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator): all_gp_objects = [o for o in context.scene.objects if o.type == 'GPENCIL'] - ## clean name and visibility + ## Clean name and visibility if self.clean_name_and_visibility: for o in all_gp_objects: if o.hide_render: @@ -208,10 +208,10 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator): l.info = l.info + o.name.lower() ## Make used prefix visible ?? (maybe some layer were intentionally hidden...) - if (res := re.search(r'^([A-Z]{2})_', l.info)): - if res.group(1) in prefix_to_render and l.hide == True and not 'invisible' in l.info: - print(f'{o.name} -> {l.info} : Switch visibility On') - l.hide = False + # if (res := re.search(r'^([A-Z]{2})_', l.info)): + # if res.group(1) in prefix_to_render and l.hide == True and not 'invisible' in l.info: + # print(f'{o.name} -> {l.info} : Switch visibility On') + # l.hide = False if self.clean_material_duplication: print('Clean material duplicates') diff --git a/OP_setup_layers.py b/OP_setup_layers.py index 364f8d0..ca37c12 100644 --- a/OP_setup_layers.py +++ b/OP_setup_layers.py @@ -223,7 +223,7 @@ class GPEXP_OT_layers_state(bpy.types.Operator): \nAffect all layers)') # , options={'SKIP_SAVE'} opacity_exclude_list : StringProperty(name='Skip', - default='MA', description='Skip prefixes from this list when changing opacity\ + default='MA, MASK, mask, MSK, msk', description='Skip prefixes from this list when changing opacity\ \nSeparate multiple value with a comma (ex: MAIN)') # , options={'SKIP_SAVE'} hide_invisible_materials : BoolProperty(name='Hide Materials named invisible', @@ -297,11 +297,15 @@ class GPEXP_OT_layers_state(bpy.types.Operator): if l.opacity != 1: - # TODO Skip zeroed opacity ? - # check if there is an exclusion word - if any(x.strip() + '_' in l.info for x in self.opacity_exclude_list.strip(',').split(',') if x): - print(f'Skipped layer : {l.info}') + if l.opacity == 0: + ## Skip layer with zero opacity + print(f'Skipped layer opacity reset (0 opacity) : {l.info}') + + elif any(x.strip() + '_' in l.info for x in self.opacity_exclude_list.strip(',').split(',') if x): + # Skip layer if name has exclusion prefix + print(f'Skipped layer opacity reset (prefix in exclusion list) : {l.info}') else: + ## Set full opacity full_opacity_state = '' if self.set_full_opacity else ' (check only)' mess = f'{l.info} : opacity {l.opacity:.2f} >> 1.0{full_opacity_state}' print(mess) @@ -341,7 +345,7 @@ class GPEXP_OT_layers_state(bpy.types.Operator): if changes: changes.append('') - ## disable multiframe editing on all GP (can cause artifacts on render) + ## Disable multiframe editing on all GP (can cause artifacts on render) gp_mu_edit_ct = 0 for gp in bpy.data.grease_pencils: if gp.use_multiedit: diff --git a/__init__.py b/__init__.py index 8930bda..3857bb3 100644 --- a/__init__.py +++ b/__init__.py @@ -2,7 +2,7 @@ bl_info = { "name": "GP Render", "description": "Organise export of gp layers through compositor output", "author": "Samuel Bernou", - "version": (1, 8, 2), + "version": (1, 8, 3), "blender": (3, 0, 0), "location": "View3D", "warning": "", diff --git a/gen_vlayer.py b/gen_vlayer.py index 0d21302..d43960d 100644 --- a/gen_vlayer.py +++ b/gen_vlayer.py @@ -518,9 +518,10 @@ def export_gp_objects(oblist, exclude_list=[], scene=None, node_scene=None, base for l in ob.data.layers: # if l.hide: # continue - if l.hide or any(x + '_' in l.info for x in exclude_list): # exclude hided ? + if l.hide or l.opacity == 0 or any(x + '_' in l.info for x in exclude_list): print(f'Exclude export: {ob.name} : {l.info}') - l.viewlayer_render = fn.get_view_layer('exclude', scene=scene).name # assign "exclude" + # Assign "exclude" layer + l.viewlayer_render = fn.get_view_layer('exclude', scene=scene).name continue get_set_viewlayer_from_gp(ob, l, scene=scene, node_scene=node_scene,