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 3844a91715 - Show all commits

View File

@ -6,7 +6,7 @@ const JOB_TYPE = {
// Settings for artists to determine:
{ key: "frame", type: "int32", required: true, eval: "C.scene.frame_current",
description: "Frame to render"},
{ key: "chunk_size", type: "int32", default: 128, propargs: {min: 1}, description: "Number of samples to render in one Blender render task",
{ key: "tile_size", type: "int32", default: 5, propargs: {min: 1, max: 100}, description: "Tile size for each Task (sizes are in % of the full image)",
visible: "submission" },
@ -86,39 +86,42 @@ function renderOutputPath(job) {
});
}
function tileChunker(tile_size) {
let tiles = [];
const rows = Math.floor(100 / tile_size);
const columns = Math.floor(100 / tile_size);
for (let row = 1; row <= rows; row++) {
for (let column = 1; column <= columns; column++) {
tiles.push({"row": row, "column": column});
}
}
return tiles;
}
function authorRenderTasks(settings, renderDir, renderOutput) {
print("authorRenderTasks(", renderDir, renderOutput, ")");
let renderTasks = [];
let chunks = frameChunker(settings.samples, settings.chunk_size);
for (let chunk of chunks) {
const task = author.Task(`render-${chunk}`, "blender");
let chunk_arr = chunk.split("-", 2);
let chunk_end;
let chunk_start;
if (chunk_arr.length < 2) {
chunk_end = chunk_arr[0];
chunk_start = chunk_arr[0] - 1;
}
else {
chunk_end = chunk_arr[1];
chunk_start = chunk_arr[0] - 1;
}
let chunk_size = chunk_end - chunk_start;
let tiles = tileChunker(settings.tile_size);
print(tiles);
for (let tile of tiles) {
const task = author.Task(`render-r${tile.row}c${tile.column}`, "blender");
let pythonExpression = `
import bpy
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.scene.render.use_compositing = False
bpy.context.scene.cycles.use_denoising = False
bpy.context.scene.render.image_settings.file_format = 'OPEN_EXR_MULTILAYER'
bpy.context.scene.cycles.samples = ${chunk_size}
bpy.context.scene.cycles.sample_offset = ${chunk_start}`;
bpy.context.scene.render.use_crop_to_border = False
bpy.context.scene.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
bpy.context.scene.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`;
if (settings.use_denoising) {
pythonExpression += `
for layer in bpy.context.scene.view_layers:
layer['cycles']['denoising_store_passes'] = 1
layer.use_pass_vector = True`;
}
print(pythonExpression);
const command = author.Command("blender-render", {
exe: "{blender}",
exeArgs: "{blenderArgs}",
@ -127,7 +130,7 @@ for layer in bpy.context.scene.view_layers:
args: [
"--python-exit-code", 1,
"--python-expr", pythonExpression,
"--render-output", path.join(renderDir, path.basename(renderOutput), "samples", chunk),
"--render-output", path.join(renderDir, path.basename(renderOutput), "tiles", "r" + tile.row + "c" + tile.column),
"--render-frame", settings.frame
]
});
@ -145,7 +148,7 @@ import pathlib
import bpy
basepath = "${renderOutput}/"
renders = basepath + "samples/"
renders = basepath + "tiles/"
tmp = basepath + 'merge_tmp/'
filenames = [f for f in os.listdir(renders) if os.path.isfile(renders + f)]
filenames.sort()