set default file output to EXR multilayer

1.6.2

- changed: Default fileout format changed from `OPEN_EXR` to `OPEN_EXR_MULTILAYER` (a `FILE_FORMAT` env variable can be set to specify nodes format)
- changed: Default compression changed from `ZIP` to `PIZ`
- changed: Rename/renumber function consider OPEN_EXR_MULTILAYER to affect `layer_slots` instead of `file_slots`
main
pullusb 2024-02-22 17:29:41 +01:00
parent 9820f273c2
commit b973668f02
4 changed files with 41 additions and 16 deletions

View File

@ -14,6 +14,12 @@ Activate / deactivate layer opacity according to prefix
Activate / deactivate all masks using MA layers
-->
1.6.2
- changed: Default fileout format changed from `OPEN_EXR` to `OPEN_EXR_MULTILAYER` (a `FILE_FORMAT` env variable can be set to specify nodes format)
- changed: Default compression changed from `ZIP` to `PIZ`
- changed: Rename/renumber function consider OPEN_EXR_MULTILAYER to affect `layer_slots` instead of `file_slots`
1.6.1
- fixed: preview output for Blender 4.0+

View File

@ -64,8 +64,6 @@ def check_file_output_numbering(reports=None):
continue
file_outs += [n for n in S.node_tree.nodes if n.type == 'OUTPUT_FILE']
used=False
if not file_outs:
reports.append('No file output nodes found')
return reports
@ -74,11 +72,12 @@ def check_file_output_numbering(reports=None):
if not prenum.match(fo.base_path.split('/')[-1]):
reports.append(f'No object numbering : node {fo.name}')
pct = 0
for fs in fo.file_slots:
slots = fo.layer_slots if fo.format.file_format == 'OPEN_EXR_MULTILAYER' else fo.file_slots
for fs in slots:
if not prenum.match(fs.path.split('/')[0]):
pct += 1
if pct:
reports.append(f'{pct}/{len(fo.file_slots)} slots not numbered: node {fo.name}')
reports.append(f'{pct}/{len(slots)} slots not numbered: node {fo.name}')
return reports
class GPEXP_OT_check_render_scene(bpy.types.Operator):

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, 6, 1),
"version": (1, 6, 2),
"blender": (3, 0, 0),
"location": "View3D",
"warning": "",

40
fn.py
View File

@ -150,12 +150,15 @@ def copy_settings(obj_a, obj_b):
pass
def set_file_output_format(fo):
fo.format.file_format = 'OPEN_EXR'
# FIXME for now default fallback to multilayer
env_file_format = os.environ.get('FILE_FORMAT')
fo.format.file_format = env_file_format if env_file_format else 'OPEN_EXR_MULTILAYER'
# fo.format.file_format = 'OPEN_EXR' # 'OPEN_EXR_MULTILAYER'
fo.format.color_mode = 'RGBA'
fo.format.color_depth = '16'
fo.format.exr_codec = 'ZIP'
# fo.format.exr_codec = 'RLE'
fo.format.exr_codec = 'PIZ' # 'ZIP', 'RLE'
## PNG format
# fo.format.file_format = 'PNG'
# fo.format.color_mode = 'RGBA'
# fo.format.color_depth = '8'
@ -898,21 +901,26 @@ def get_numbered_output(out, slot_name):
def add_fileslot_number(fs, number):
elems = fs.path.split('/')
field_attr = 'name' if hasattr(fs, 'name') else 'path'
elems = getattr(fs, field_attr).split('/')
for i, e in enumerate(elems):
if re.match(r'^\d{3}_', e):
elems[i] = re.sub(r'^(\d{3})', lambda x: str(number).zfill(3), e)
else:
elems[i] = f'{str(number).zfill(3)}_{e}'
new = '/'.join(elems)
fs.path = new
setattr(fs, field_attr, new)
return new
def renumber(fo, offset=10):
'''Force renumber all the slots with a 3'''
if fo.type != 'OUTPUT_FILE': return
ct = 10 # start at 10
for fs in fo.file_slots:
slots = fo.layer_slots if fo.format.file_format == 'OPEN_EXR_MULTILAYER' else fo.file_slots
for fs in slots:
add_fileslot_number(fs, ct)
ct += offset
@ -921,7 +929,11 @@ def get_num(string) -> int:
return leading number or None
'''
if not isinstance(string, str):
if hasattr(string, 'path'):
string = string.path
else:
string = string.name
num = re.search(r'^(\d{3})_', string)
if num:
return int(num.group(1))
@ -930,13 +942,21 @@ def delete_numbering(fo): # padding=3
'''Delete prefix numbering on all slots on passed file output'''
if fo.type != 'OUTPUT_FILE': return
for fs in fo.file_slots:
elems = fs.path.split('/')
if fo.format.file_format == 'OPEN_EXR_MULTILAYER':
slots = fo.layer_slots
field_attr = 'name'
else:
slots = fo.file_slots
field_attr = 'path'
for fs in slots:
elems = getattr(fs, field_attr).split('/')
for i, e in enumerate(elems):
elems[i] = re.sub(r'^\d{3}_', '', e)
new = '/'.join(elems)
fs.path = new
setattr(fs, field_attr, new)
def reverse_fileout_inputs(fo):
count = len(fo.inputs)
@ -954,7 +974,7 @@ def renumber_keep_existing(fo, offset=10, invert=True):
if invert:
reverse_fileout_inputs(fo)
fsl = fo.file_slots
fsl = fo.layer_slots if fo.format.file_format == 'OPEN_EXR_MULTILAYER' else fo.file_slots
last_idx = len(fsl) - 1
prev = None