WIP: Single-frame job compiler #104194
@ -162,11 +162,8 @@ bpy.context.scene.render.resolution_y = ${settings.resolution_y}
|
|||||||
bpy.context.scene.render.resolution_percentage = ${settings.resolution_percentage}
|
bpy.context.scene.render.resolution_percentage = ${settings.resolution_percentage}
|
||||||
bpy.context.scene.render.use_compositing = True
|
bpy.context.scene.render.use_compositing = True
|
||||||
bpy.context.scene.use_nodes = True
|
bpy.context.scene.use_nodes = True
|
||||||
bpy.context.scene.view_layers[0].use = False
|
bpy.context.scene.node_tree.nodes.clear()
|
||||||
if 'Render Layers' in bpy.context.scene.node_tree.nodes:
|
|
||||||
bpy.context.scene.node_tree.nodes.remove(bpy.context.scene.node_tree.nodes['Render Layers'])
|
|
||||||
bpy.context.scene.render.image_settings.file_format = 'OPEN_EXR_MULTILAYER'
|
bpy.context.scene.render.image_settings.file_format = 'OPEN_EXR_MULTILAYER'
|
||||||
bpy.context.scene.render.filepath = basepath + "MERGED"
|
|
||||||
|
|
||||||
image_nodes = []
|
image_nodes = []
|
||||||
for index, image in enumerate(filenames):
|
for index, image in enumerate(filenames):
|
||||||
@ -189,9 +186,11 @@ for index, node in enumerate(image_nodes):
|
|||||||
bpy.context.scene.node_tree.links.new(image_nodes[index+1].outputs['Combined'], alpha_over_nodes[index].inputs[2])
|
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:
|
if index + 1 == len(image_nodes) - 1:
|
||||||
# Link the last image node and feed the output into the composite node
|
# 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'])
|
output_node = bpy.context.scene.node_tree.nodes.new(type='CompositorNodeOutputFile')
|
||||||
|
output_node.base_path = basepath + "MERGED"
|
||||||
|
bpy.context.scene.node_tree.links.new(alpha_over_nodes[index].outputs['Image'], output_node.inputs['Image'])
|
||||||
break
|
break
|
||||||
bpy.ops.render.render(write_still=True)`;
|
bpy.ops.render.render()`;
|
||||||
const command = author.Command("blender-render", {
|
const command = author.Command("blender-render", {
|
||||||
exe: "{blender}",
|
exe: "{blender}",
|
||||||
exeArgs: "{blenderArgs}",
|
exeArgs: "{blenderArgs}",
|
||||||
@ -231,18 +230,18 @@ bpy.ops.cycles.denoise_animation(input_filepath="${renderOutput}/MERGED.exr", ou
|
|||||||
|
|
||||||
function authorCreateCompositeTask(settings, renderOutput) {
|
function authorCreateCompositeTask(settings, renderOutput) {
|
||||||
let filename;
|
let filename;
|
||||||
if (settings.use_denoising) {
|
|
||||||
filename = "DENOISED.exr";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
filename = "MERGED.exr";
|
|
||||||
}
|
|
||||||
let pythonExpression = `
|
let pythonExpression = `
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
C = bpy.context
|
C = bpy.context
|
||||||
basepath = "${renderOutput}/"
|
basepath = "${renderOutput}/"
|
||||||
filename = "${filename}"`;
|
filenames = [f for f in os.listdir(basepath) if os.path.isfile(basepath + f)]
|
||||||
|
if "DENOISED.exr" in filenames:
|
||||||
|
filename = "DENOISED.exr"
|
||||||
|
else:
|
||||||
|
filename = next((s for s in filenames if "MERGED" in s), None)
|
||||||
|
`;
|
||||||
if (settings.use_compositing) {
|
if (settings.use_compositing) {
|
||||||
// Do the full composite+export pipeline
|
// Do the full composite+export pipeline
|
||||||
// uses snippets from
|
// uses snippets from
|
||||||
@ -265,7 +264,7 @@ for node in C.scene.node_tree.nodes:
|
|||||||
if link.from_node != node:
|
if link.from_node != node:
|
||||||
continue
|
continue
|
||||||
print('DEBUG: Found link %s - %s' % (link.from_socket, link.to_socket))
|
print('DEBUG: Found link %s - %s' % (link.from_socket, link.to_socket))
|
||||||
link_name = "Combined"
|
link_name = "Image"
|
||||||
for output in image_node.outputs:
|
for output in image_node.outputs:
|
||||||
print('DEBUG: Checking output:', output.name, link_name)
|
print('DEBUG: Checking output:', output.name, link_name)
|
||||||
if output.name != link_name:
|
if output.name != link_name:
|
||||||
@ -287,12 +286,9 @@ C.scene.render.filepath = basepath + "FINAL"
|
|||||||
bpy.ops.render.render(write_still=True)`;
|
bpy.ops.render.render(write_still=True)`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pythonExpression += `
|
|
||||||
print("Compositing is disabled")`;
|
|
||||||
if (settings.format == "OPEN_EXR_MULTILAYER") {
|
if (settings.format == "OPEN_EXR_MULTILAYER") {
|
||||||
// Only rename
|
// Only rename
|
||||||
pythonExpression += `
|
pythonExpression += `
|
||||||
print('Renaming ' + basepath + filename + ' to ' + basepath + 'FINAL.exr')
|
|
||||||
pathlib.Path(basepath + filename).rename(basepath + 'FINAL.exr')`;
|
pathlib.Path(basepath + filename).rename(basepath + 'FINAL.exr')`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -300,7 +296,6 @@ pathlib.Path(basepath + filename).rename(basepath + 'FINAL.exr')`;
|
|||||||
pythonExpression += `
|
pythonExpression += `
|
||||||
bpy.ops.image.open(filepath=basepath + filename, use_sequence_detection=False)
|
bpy.ops.image.open(filepath=basepath + filename, use_sequence_detection=False)
|
||||||
image = bpy.data.images[bpy.path.basename(filename)]
|
image = bpy.data.images[bpy.path.basename(filename)]
|
||||||
print("Saving final image to " + basepath + "FINAL" + "${settings.image_file_extension}")
|
|
||||||
image.save_render(basepath + "FINAL" + "${settings.image_file_extension}")`;
|
image.save_render(basepath + "FINAL" + "${settings.image_file_extension}")`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user