WIP: Initial version of a single-frame job compiler #104189
@ -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}",
|
||||
|
Loading…
Reference in New Issue
Block a user