WIP: Initial version of a single-frame job compiler #104189

Closed
k8ie wants to merge 26 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 fd3c1ddf98 - Show all commits

View File

@ -162,23 +162,23 @@ bpy.context.scene.node_tree.nodes.clear()
bpy.context.scene.render.image_settings.file_format = 'OPEN_EXR_MULTILAYER'
bpy.context.scene.render.filepath = basepath + "MERGED"
image_nodes = []
image_node_translates = []
for index, image in enumerate(filenames):
dimensions = {'X': int(image.split('c')[-1].split('_')[0]), 'Y': int(image.split('c')[0].replace('r', ''))}
bpy.ops.image.open(filepath=renders + image, use_sequence_detection=False)
image = bpy.data.images[bpy.path.basename(image)]
image_node = bpy.context.scene.node_tree.nodes.new(type='CompositorNodeImage')
image_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeTranslate'))
image_node_translates.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeTranslate'))
image_node.image = image
image_nodes[index].use_relative = True
bpy.context.scene.node_tree.links.new(image_node.outputs['Combined'], image_nodes[index].inputs['Image'])
image_node_translates[index].use_relative = True
bpy.context.scene.node_tree.links.new(image_node.outputs['Combined'], image_node_translates[index].inputs['Image'])
for dimension in dimensions:
if dimensions[dimension] == 0:
image_nodes[index].inputs[dimension].default_value = normalize(${settings.tile_size} / 100 / 2)
image_node_translates[index].inputs[dimension].default_value = normalize(${settings.tile_size} / 100 / 2)
elif dimensions[dimension] == row_max and 100 % ${settings.tile_size} != 0:
image_nodes[index].inputs[dimension].default_value = normalize((${settings.tile_size} / 100 + (dimensions[dimension] - 1) * ${settings.tile_size} / 100) + ((100 % ${settings.tile_size}) / 100) / 2)
image_node_translates[index].inputs[dimension].default_value = normalize((${settings.tile_size} / 100 + (dimensions[dimension] - 1) * ${settings.tile_size} / 100) + ((100 % ${settings.tile_size}) / 100) / 2)
else:
image_nodes[index].inputs[dimension].default_value = normalize((${settings.tile_size} / 100 + (dimensions[dimension] - 1) * ${settings.tile_size} / 100) + (${settings.tile_size} / 100) / 2)
image_node_translates[index].inputs[dimension].default_value = normalize((${settings.tile_size} / 100 + (dimensions[dimension] - 1) * ${settings.tile_size} / 100) + (${settings.tile_size} / 100) / 2)
output_node = bpy.context.scene.node_tree.nodes.new(type='CompositorNodeComposite')
denoising = "${settings.use_denoising}" == "true"
@ -186,36 +186,36 @@ alpha_over_nodes = []
albedo_mix_nodes = []
normal_mix_nodes = []
for index, node in enumerate(image_nodes):
for index, node in enumerate(image_node_translates):
if index == 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['Image'], alpha_over_nodes[index].inputs[1])
bpy.context.scene.node_tree.links.new(image_nodes[1].outputs['Image'], alpha_over_nodes[index].inputs[2])
bpy.context.scene.node_tree.links.new(image_node_translates[0].outputs['Image'], alpha_over_nodes[index].inputs[1])
bpy.context.scene.node_tree.links.new(image_node_translates[1].outputs['Image'], alpha_over_nodes[index].inputs[2])
if denoising:
albedo_mix_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeMixRGB'))
albedo_mix_nodes[index].blend_type = 'ADD'
bpy.context.scene.node_tree.links.new(image_nodes[0].outputs['Denoising Albedo'], albedo_mix_nodes[index].inputs[1])
bpy.context.scene.node_tree.links.new(image_nodes[1].outputs['Denoising Albedo'], albedo_mix_nodes[index].inputs[2])
bpy.context.scene.node_tree.links.new(image_node_translates[0].outputs['Denoising Albedo'], albedo_mix_nodes[index].inputs[1])
bpy.context.scene.node_tree.links.new(image_node_translates[1].outputs['Denoising Albedo'], albedo_mix_nodes[index].inputs[2])
normal_mix_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeMixRGB'))
normal_mix_nodes[index].blend_type = 'ADD'
bpy.context.scene.node_tree.links.new(image_nodes[0].outputs['Denoising Normal'], normal_mix_nodes[index].inputs[1])
bpy.context.scene.node_tree.links.new(image_nodes[1].outputs['Denoising Normal'], normal_mix_nodes[index].inputs[2])
bpy.context.scene.node_tree.links.new(image_node_translates[0].outputs['Denoising Normal'], normal_mix_nodes[index].inputs[1])
bpy.context.scene.node_tree.links.new(image_node_translates[1].outputs['Denoising Normal'], normal_mix_nodes[index].inputs[2])
else:
# 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['Image'], alpha_over_nodes[index].inputs[2])
bpy.context.scene.node_tree.links.new(image_node_translates[index+1].outputs['Image'], alpha_over_nodes[index].inputs[2])
if denoising:
albedo_mix_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeMixRGB'))
albedo_mix_nodes[index].blend_type = 'ADD'
bpy.context.scene.node_tree.links.new(albedo_mix_nodes[index-1].outputs['Image'], albedo_mix_nodes[index].inputs[1])
bpy.context.scene.node_tree.links.new(image_nodes[index+1].outputs['Denoising Albedo'], albedo_mix_nodes[index].inputs[2])
bpy.context.scene.node_tree.links.new(image_node_translates[index+1].outputs['Denoising Albedo'], albedo_mix_nodes[index].inputs[2])
normal_mix_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeMixRGB'))
normal_mix_nodes[index].blend_type = 'ADD'
bpy.context.scene.node_tree.links.new(normal_mix_nodes[index-1].outputs['Image'], normal_mix_nodes[index].inputs[1])
bpy.context.scene.node_tree.links.new(image_nodes[index+1].outputs['Denoising Normal'], normal_mix_nodes[index].inputs[2])
if index + 1 == len(image_nodes) - 1:
bpy.context.scene.node_tree.links.new(image_node_translates[index+1].outputs['Denoising Normal'], normal_mix_nodes[index].inputs[2])
if index + 1 == len(image_node_translates) - 1:
if denoising:
denoise_node = bpy.context.scene.node_tree.nodes.new(type='CompositorNodeDenoise')
bpy.context.scene.node_tree.links.new(alpha_over_nodes[index].outputs['Image'], denoise_node.inputs['Image'])