Fix file output base path
1.7.1 - fix: file output base path depending on file format - fix: problem when connecting render layersmain
parent
4627b50248
commit
16a4014da9
|
@ -14,6 +14,11 @@ Activate / deactivate layer opacity according to prefix
|
||||||
Activate / deactivate all masks using MA layers
|
Activate / deactivate all masks using MA layers
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
1.7.1
|
||||||
|
|
||||||
|
- fix: file output base path depending on file format
|
||||||
|
- fix: problem when connecting render layers
|
||||||
|
|
||||||
1.7.0
|
1.7.0
|
||||||
|
|
||||||
- fix: problem when removing render layers
|
- fix: problem when removing render layers
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
# GP Render
|
# GP Render
|
||||||
|
|
||||||
Organise export of gp layers through compositor output
|
Organise export of gp layers through compositor output
|
||||||
|
|
||||||
|
### Environment variables
|
||||||
|
|
||||||
|
`FILE_FORMAT` : Define file_format used for output. If not specified, use `OPEN_EXR_MULTILAYER` (set `OPEN_EXR` for separate sequences)
|
|
@ -2,7 +2,7 @@ bl_info = {
|
||||||
"name": "GP Render",
|
"name": "GP Render",
|
||||||
"description": "Organise export of gp layers through compositor output",
|
"description": "Organise export of gp layers through compositor output",
|
||||||
"author": "Samuel Bernou",
|
"author": "Samuel Bernou",
|
||||||
"version": (1, 7, 0),
|
"version": (1, 7, 1),
|
||||||
"blender": (3, 0, 0),
|
"blender": (3, 0, 0),
|
||||||
"location": "View3D",
|
"location": "View3D",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
|
|
31
fn.py
31
fn.py
|
@ -1906,17 +1906,19 @@ def connect_to_file_output(node_list, file_out=None):
|
||||||
fo.name = out_name
|
fo.name = out_name
|
||||||
if node.parent:
|
if node.parent:
|
||||||
fo.parent = node.parent
|
fo.parent = node.parent
|
||||||
|
|
||||||
|
if fo.format.file_format == 'OPEN_EXR_MULTILAYER':
|
||||||
|
fo.base_path = f'//render/{out_base}/{out_base}_'
|
||||||
|
else:
|
||||||
fo.base_path = f'//render/{out_base}'
|
fo.base_path = f'//render/{out_base}'
|
||||||
|
|
||||||
for o in outs:
|
for o in outs:
|
||||||
# if o.name == 'Deprecated':
|
|
||||||
# continue
|
|
||||||
|
|
||||||
## Skip if already connected to current FO
|
|
||||||
# if next((l for l in o.links if l.to_node == fo), None):
|
|
||||||
if next((l for l in o.links if recursive_node_connect_check(l, fo)), None):
|
if next((l for l in o.links if recursive_node_connect_check(l, fo)), None):
|
||||||
continue
|
continue
|
||||||
slot_name = bpy.path.clean_name(o.name)
|
slot_name = bpy.path.clean_name(o.name)
|
||||||
|
if fo.format.file_format == 'OPEN_EXR_MULTILAYER':
|
||||||
|
slot_name = slot_name
|
||||||
|
else:
|
||||||
slot_name = f'{slot_name}/{slot_name}_'
|
slot_name = f'{slot_name}/{slot_name}_'
|
||||||
fo.file_slots.new(slot_name)
|
fo.file_slots.new(slot_name)
|
||||||
out_input = fo.inputs[-1]
|
out_input = fo.inputs[-1]
|
||||||
|
@ -1933,15 +1935,18 @@ def connect_to_file_output(node_list, file_out=None):
|
||||||
if not fo:
|
if not fo:
|
||||||
# color = (0.2,0.3,0.5)
|
# color = (0.2,0.3,0.5)
|
||||||
fo = create_node('CompositorNodeOutputFile', tree=scene.node_tree, location=(real_loc(node)[0]+400, real_loc(node)[1]-200), width=220)
|
fo = create_node('CompositorNodeOutputFile', tree=scene.node_tree, location=(real_loc(node)[0]+400, real_loc(node)[1]-200), width=220)
|
||||||
set_file_output_format(fo)
|
set_file_output_format(fo) # OPEN_EXR_MULTILAYER, RGBA, ZIP
|
||||||
fo.format.file_format = 'OPEN_EXR_MULTILAYER'
|
|
||||||
fo.format.color_mode = 'RGBA'
|
|
||||||
fo.format.color_depth = '32'
|
fo.format.color_depth = '32'
|
||||||
fo.format.exr_codec = 'ZIP'
|
|
||||||
fo.name = out_name
|
fo.name = out_name
|
||||||
if node.parent:
|
if node.parent:
|
||||||
fo.parent = node.parent
|
fo.parent = node.parent
|
||||||
|
|
||||||
|
if fo.format.file_format == 'OPEN_EXR_MULTILAYER':
|
||||||
|
## FIXME: find a better organization for separated crypto pass
|
||||||
fo.base_path = f'//render/{out_base}/cryptos/cryptos_'
|
fo.base_path = f'//render/{out_base}/cryptos/cryptos_'
|
||||||
|
else:
|
||||||
|
fo.base_path = f'//render/{out_base}'
|
||||||
|
# fo.base_path = f'//render/{out_base}/cryptos'
|
||||||
|
|
||||||
for o in cryptout:
|
for o in cryptout:
|
||||||
## Skip already connected
|
## Skip already connected
|
||||||
|
@ -1949,8 +1954,14 @@ def connect_to_file_output(node_list, file_out=None):
|
||||||
# if next((l for l in o.links if l.to_node == fo), None):
|
# if next((l for l in o.links if l.to_node == fo), None):
|
||||||
if next((l for l in o.links if recursive_node_connect_check(l, fo)), None):
|
if next((l for l in o.links if recursive_node_connect_check(l, fo)), None):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
slot_name = bpy.path.clean_name(o.name) # directly use name in multi layer exr
|
slot_name = bpy.path.clean_name(o.name) # directly use name in multi layer exr
|
||||||
# slot_name = f'{slot_name}/{slot_name}_'
|
|
||||||
|
if fo.format.file_format == 'OPEN_EXR_MULTILAYER':
|
||||||
|
slot_name = slot_name
|
||||||
|
else:
|
||||||
|
slot_name = f'{slot_name}/{slot_name}_'
|
||||||
|
|
||||||
fo.file_slots.new(slot_name)
|
fo.file_slots.new(slot_name)
|
||||||
out_input = fo.inputs[-1]
|
out_input = fo.inputs[-1]
|
||||||
links.new(o, out_input)
|
links.new(o, out_input)
|
||||||
|
|
|
@ -103,13 +103,14 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None):
|
||||||
ng.node_tree = ngroup
|
ng.node_tree = ngroup
|
||||||
ng.name = ngroup.name
|
ng.name = ngroup.name
|
||||||
|
|
||||||
ng_in = fn.create_node('NodeGroupInput', tree=ngroup, location=(-600,0))
|
|
||||||
ng_out = fn.create_node('NodeGroupOutput', tree=ngroup, location=(600,0))
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
ngroup = ng.node_tree
|
ngroup = ng.node_tree
|
||||||
ng_in = ngroup.nodes.get('Group Input')
|
|
||||||
ng_out = ngroup.nodes.get('Group Output')
|
if not (ng_in := ngroup.nodes.get('Group Input')):
|
||||||
|
ng_in = fn.create_node('NodeGroupInput', tree=ngroup, location=(-600,0))
|
||||||
|
|
||||||
|
if not (ng_out := ngroup.nodes.get('Group Output')):
|
||||||
|
ng_out = fn.create_node('NodeGroupOutput', tree=ngroup, location=(600,0))
|
||||||
|
|
||||||
# Connect rlayer to nodegroup
|
# Connect rlayer to nodegroup
|
||||||
if not rlayer.outputs['Image'].is_linked:
|
if not rlayer.outputs['Image'].is_linked:
|
||||||
|
@ -127,14 +128,19 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None):
|
||||||
# rl_nodes = [n for n in nodes if n.type == 'R_LAYERS' and n.layer != 'View Layer' and n.parent == frame]
|
# rl_nodes = [n for n in nodes if n.type == 'R_LAYERS' and n.layer != 'View Layer' and n.parent == frame]
|
||||||
|
|
||||||
# auto clean : if an input exists but is not linked and name not exists in rlayers of current frame
|
# auto clean : if an input exists but is not linked and name not exists in rlayers of current frame
|
||||||
|
|
||||||
|
if bpy.app.version < (4,0,0):
|
||||||
for s in reversed(ng.inputs):
|
for s in reversed(ng.inputs):
|
||||||
if not s.is_linked: # and not any(x.layer == s.name for x in rl_nodes)
|
if not s.is_linked: # and not any(x.layer == s.name for x in rl_nodes)
|
||||||
print(f'removing grp unlinked input {s.name}')
|
print(f'Removing unlinked input {s.name}')
|
||||||
# ng.inputs.remove(s)
|
ng.inputs.remove(s)
|
||||||
if bpy.app.version < (4,0,0):
|
|
||||||
ng.node_tree.inputs.remove(s)
|
|
||||||
else:
|
else:
|
||||||
ng.node_tree.interface.items_tree.remove(s)
|
g_inputs = [s for s in ngroup.interface.items_tree if s.in_out == 'INPUT']
|
||||||
|
# g_outputs = [s for s in ngroup.interface.items_tree if s.in_out == 'OUTPUT']
|
||||||
|
for i in range(len(ng.inputs))[::-1]:
|
||||||
|
if not ng.inputs[i].is_linked:
|
||||||
|
print(f'Removing unlinked input {ng.inputs[i].name}')
|
||||||
|
ngroup.interface.remove(g_inputs[i])
|
||||||
|
|
||||||
## get nodes from linked NG inputs ??? maybe more clear...
|
## get nodes from linked NG inputs ??? maybe more clear...
|
||||||
# rl_nodes = [s.links[0].from_node for s in ng.inputs if s.links and s.links[0].from_node and s.links[0].from_node.type == 'R_LAYERS']
|
# rl_nodes = [s.links[0].from_node for s in ng.inputs if s.links and s.links[0].from_node and s.links[0].from_node.type == 'R_LAYERS']
|
||||||
|
@ -228,7 +234,11 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None):
|
||||||
fn.set_file_output_format(out)
|
fn.set_file_output_format(out)
|
||||||
out.name = out_name
|
out.name = out_name
|
||||||
out.parent = frame
|
out.parent = frame
|
||||||
out.base_path = f'//render/{bpy.path.clean_name(obname)}'
|
out_base = {bpy.path.clean_name(obname)}
|
||||||
|
if out.format.file_format == 'OPEN_EXR_MULTILAYER':
|
||||||
|
out.base_path = f'//render/{out_base}/{out_base}_'
|
||||||
|
else:
|
||||||
|
out.base_path = f'//render/{out_base}'
|
||||||
|
|
||||||
## out_input = out.inputs.get(slot_name) # ok for non-numbered outputs
|
## out_input = out.inputs.get(slot_name) # ok for non-numbered outputs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue