WIP: Initial version of a single-frame job compiler #104189
@ -97,15 +97,16 @@ function authorRenderTasks(settings, renderDir, renderOutput) {
|
|||||||
const task = author.Task(`render-r${tile.row}c${tile.column}`, "blender");
|
const task = author.Task(`render-r${tile.row}c${tile.column}`, "blender");
|
||||||
let pythonExpression = `
|
let pythonExpression = `
|
||||||
import bpy
|
import bpy
|
||||||
bpy.context.scene.render.engine = 'CYCLES'
|
render = bpy.context.scene.render
|
||||||
bpy.context.scene.render.use_compositing = False
|
render.engine = 'CYCLES'
|
||||||
|
render.use_compositing = False
|
||||||
bpy.context.scene.cycles.use_denoising = False
|
bpy.context.scene.cycles.use_denoising = False
|
||||||
bpy.context.scene.render.image_settings.file_format = 'OPEN_EXR_MULTILAYER'
|
render.image_settings.file_format = 'OPEN_EXR_MULTILAYER'
|
||||||
bpy.context.scene.render.use_crop_to_border = False
|
render.use_crop_to_border = True
|
||||||
bpy.context.scene.render.border_min_x = ${tile.column} * ${settings.tile_size} / 100
|
render.border_min_x = ${tile.column} * ${settings.tile_size} / 100
|
||||||
bpy.context.scene.render.border_max_x = ${settings.tile_size} / 100 + ${tile.column} * ${settings.tile_size} / 100
|
render.border_max_x = ${settings.tile_size} / 100 + ${tile.column} * ${settings.tile_size} / 100
|
||||||
bpy.context.scene.render.border_min_y = ${tile.row} * ${settings.tile_size} / 100
|
render.border_min_y = ${tile.row} * ${settings.tile_size} / 100
|
||||||
bpy.context.scene.render.border_max_y = ${settings.tile_size} / 100 + ${tile.row} * ${settings.tile_size} / 100`;
|
render.border_max_y = ${settings.tile_size} / 100 + ${tile.row} * ${settings.tile_size} / 100`;
|
||||||
if (settings.use_denoising) {
|
if (settings.use_denoising) {
|
||||||
pythonExpression += `
|
pythonExpression += `
|
||||||
for layer in bpy.context.scene.view_layers:
|
for layer in bpy.context.scene.view_layers:
|
||||||
@ -120,7 +121,7 @@ for layer in bpy.context.scene.view_layers:
|
|||||||
args: [
|
args: [
|
||||||
"--python-exit-code", 1,
|
"--python-exit-code", 1,
|
||||||
"--python-expr", pythonExpression,
|
"--python-expr", pythonExpression,
|
||||||
"--render-output", path.join(renderDir, path.basename(renderOutput), "tiles", "r" + tile.row + "c" + tile.column),
|
"--render-output", path.join(renderDir, path.basename(renderOutput), "tiles", "r" + tile.row + "c" + tile.column + "_"),
|
||||||
"--render-frame", settings.frame
|
"--render-frame", settings.frame
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
@ -136,17 +137,23 @@ function authorCreateMergeTask(settings, renderOutput) {
|
|||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import bpy
|
import bpy
|
||||||
|
import math
|
||||||
|
|
||||||
|
def normalize(number):
|
||||||
|
return round(-0.5 + (number - 0) * (0.5 - -0.5) / 1 - 0, 10)
|
||||||
|
|
||||||
basepath = "${renderOutput}/"
|
basepath = "${renderOutput}/"
|
||||||
renders = basepath + "tiles/"
|
renders = basepath + "tiles/"
|
||||||
filenames = [f for f in os.listdir(renders) if os.path.isfile(renders + f)]
|
filenames = [f for f in os.listdir(renders) if os.path.isfile(renders + f)]
|
||||||
filenames.sort()
|
|
||||||
if len(filenames) <= 1:
|
if len(filenames) <= 1:
|
||||||
print('This job only has one file, merging not required.')
|
print('This job only has one file, merging not required.')
|
||||||
print('Moving ' + renders + filenames[0] + ' to ' + basepath + 'MERGED.exr')
|
print('Moving ' + renders + filenames[0] + ' to ' + basepath + 'MERGED.exr')
|
||||||
pathlib.Path(renders + filenames[0]).rename(basepath + 'MERGED.exr')
|
pathlib.Path(renders + filenames[0]).rename(basepath + 'MERGED.exr')
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
|
row_max = math.ceil(100 / ${settings.tile_size}) - 1
|
||||||
|
|
||||||
bpy.context.scene.render.resolution_x = ${settings.resolution_x}
|
bpy.context.scene.render.resolution_x = ${settings.resolution_x}
|
||||||
bpy.context.scene.render.resolution_y = ${settings.resolution_y}
|
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}
|
||||||
@ -158,10 +165,21 @@ bpy.context.scene.render.filepath = basepath + "MERGED"
|
|||||||
|
|
||||||
image_nodes = []
|
image_nodes = []
|
||||||
for index, image in enumerate(filenames):
|
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)
|
bpy.ops.image.open(filepath=renders + image, use_sequence_detection=False)
|
||||||
image = bpy.data.images[bpy.path.basename(image)]
|
image = bpy.data.images[bpy.path.basename(image)]
|
||||||
image_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeImage'))
|
image_node = bpy.context.scene.node_tree.nodes.new(type='CompositorNodeImage')
|
||||||
image_nodes[index].image = image
|
image_nodes.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'])
|
||||||
|
for dimension in dimensions:
|
||||||
|
if dimensions[dimension] == 0:
|
||||||
|
image_nodes[index].inputs[dimension].default_value = normalize(${settings.tile_size} / 100 / 2)
|
||||||
|
elif dimensions[dimension] == row_max:
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
|
||||||
output_node = bpy.context.scene.node_tree.nodes.new(type='CompositorNodeComposite')
|
output_node = bpy.context.scene.node_tree.nodes.new(type='CompositorNodeComposite')
|
||||||
denoising = "${settings.use_denoising}" == "true"
|
denoising = "${settings.use_denoising}" == "true"
|
||||||
@ -173,8 +191,8 @@ for index, node in enumerate(image_nodes):
|
|||||||
if index == 0:
|
if index == 0:
|
||||||
# Take the first two image nodes and combine them
|
# Take the first two image nodes and combine them
|
||||||
alpha_over_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeAlphaOver'))
|
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[index].inputs[1])
|
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['Combined'], alpha_over_nodes[index].inputs[2])
|
bpy.context.scene.node_tree.links.new(image_nodes[1].outputs['Image'], alpha_over_nodes[index].inputs[2])
|
||||||
if denoising:
|
if denoising:
|
||||||
albedo_mix_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeMixRGB'))
|
albedo_mix_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeMixRGB'))
|
||||||
albedo_mix_nodes[index].blend_type = 'ADD'
|
albedo_mix_nodes[index].blend_type = 'ADD'
|
||||||
@ -188,7 +206,7 @@ for index, node in enumerate(image_nodes):
|
|||||||
# Take one image node and the previous alpha over node
|
# Take one image node and the previous alpha over node
|
||||||
alpha_over_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeAlphaOver'))
|
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(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])
|
bpy.context.scene.node_tree.links.new(image_nodes[index+1].outputs['Image'], alpha_over_nodes[index].inputs[2])
|
||||||
if denoising:
|
if denoising:
|
||||||
albedo_mix_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeMixRGB'))
|
albedo_mix_nodes.append(bpy.context.scene.node_tree.nodes.new(type='CompositorNodeMixRGB'))
|
||||||
albedo_mix_nodes[index].blend_type = 'ADD'
|
albedo_mix_nodes[index].blend_type = 'ADD'
|
||||||
|
Loading…
Reference in New Issue
Block a user