WIP: Single-frame job compiler #104194

Draft
k8ie wants to merge 30 commits from k8ie/flamenco:single-frame into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit 342e3d13cf - Show all commits

View File

@ -149,7 +149,6 @@ import bpy
basepath = "${renderOutput}/"
renders = basepath + "tiles/"
tmp = basepath + 'merge_tmp/'
filenames = [f for f in os.listdir(renders) if os.path.isfile(renders + f)]
filenames.sort()
if len(filenames) <= 1:
@ -157,24 +156,33 @@ if len(filenames) <= 1:
print('Moving ' + renders + filenames[0] + ' to ' + basepath + 'MERGED.exr')
pathlib.Path(renders + filenames[0]).rename(basepath + 'MERGED.exr')
exit()
if not os.path.exists(tmp):
os.makedirs(tmp)
index = 0
while len(filenames) > 0:
image_nodes = []
for index, image in enumerate(filenames):
bpy.ops.image.open(filepath=renders + image, use_sequence_detection=False)
image = bpy.data.images[bpy.path.basename(image)]
image_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeImage'))
image_nodes[index].image = image
alpha_over_nodes = []
for index, node in enumerate(image_nodes):
if index == 0:
print('Merging ' + renders + filenames[0] + ' and ' + renders + filenames[1])
bpy.ops.cycles.merge_images(input_filepath1=renders + filenames[0], input_filepath2=renders + filenames[1], output_filepath=tmp + str(index)+'.exr')
del filenames[0]
del filenames[0]
# Take the first two image nodes and combine them
alpha_over_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeAlphaOver'))
bpy.context.scene.node_tree.links.new(image_nodes[0].outputs['Combined'], alpha_over_nodes[0].inputs[1])
bpy.context.scene.node_tree.links.new(image_nodes[1].outputs['Combined'], alpha_over_nodes[0].inputs[2])
else:
print('Merging ' + tmp + str(index - 1) + '.exr' + ' and ' + renders + filenames[0])
bpy.ops.cycles.merge_images(input_filepath1=tmp + str(index - 1) + '.exr', input_filepath2=renders + filenames[0], output_filepath=tmp + str(index) + '.exr')
del filenames[0]
index += 1
print('Moving ' + tmp + str(index-1) + '.exr' + ' to ' + basepath + 'MERGED.exr')
pathlib.Path(tmp + str(index-1)+'.exr').rename(basepath + 'MERGED.exr')`;
# Take one image node and the previous alpha over node
alpha_over_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeAlphaOver'))
bpy.context.scene.node_tree.links.new(alpha_over_nodes[index-1].outputs['Image'], alpha_over_nodes[index].inputs[1])
bpy.context.scene.node_tree.links.new(image_nodes[index+1].outputs['Combined'], alpha_over_nodes[index].inputs[2])
if index + 1 == len(image_nodes) - 1:
# Link the last image node and feed the output into the composite node
bpy.context.scene.node_tree.links.new(alpha_over_nodes[index].outputs['Image'], bpy.context.scene.node_tree.nodes['Composite'].inputs['Image'])
break
`;
const command = author.Command("blender-render", {
exe: "{blender}",
exeArgs: "{blenderArgs}",