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`)
main
pullusb 2024-09-09 14:38:16 +02:00
parent 2f8efed73b
commit ea0561e14e
5 changed files with 27 additions and 15 deletions

View File

@ -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

View File

@ -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')

View File

@ -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:

View File

@ -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": "",

View File

@ -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,