WIP: Single-frame job compiler #104194
@ -55,8 +55,8 @@ function compileJob(job) {
|
|||||||
mergeTask.addDependency(rt);
|
mergeTask.addDependency(rt);
|
||||||
}
|
}
|
||||||
job.addTask(mergeTask);
|
job.addTask(mergeTask);
|
||||||
compositeTask.addDependency(mergeTask);
|
compositeTask.addDependency(mergeTask);
|
||||||
job.addTask(compositeTask);
|
job.addTask(compositeTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do field replacement on the render output path.
|
// Do field replacement on the render output path.
|
||||||
@ -76,15 +76,15 @@ function renderOutputPath(job) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tileChunker(tile_size) {
|
function tileChunker(tile_size) {
|
||||||
let tiles = [];
|
let tiles = [];
|
||||||
const rows = Math.ceil(100 / tile_size);
|
const rows = Math.ceil(100 / tile_size);
|
||||||
const columns = Math.ceil(100 / tile_size);
|
const columns = Math.ceil(100 / tile_size);
|
||||||
for (let row = 0; row < rows; row++) {
|
for (let row = 0; row < rows; row++) {
|
||||||
for (let column = 0; column < columns; column++) {
|
for (let column = 0; column < columns; column++) {
|
||||||
tiles.push({"row": row, "column": column});
|
tiles.push({"row": row, "column": column});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
function authorRenderTasks(settings, renderDir, renderOutput) {
|
function authorRenderTasks(settings, renderDir, renderOutput) {
|
||||||
@ -111,8 +111,8 @@ render.border_max_y = tile_size_decimal + ${tile.row} * tile_size_decimal`;
|
|||||||
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:
|
||||||
layer['cycles']['denoising_store_passes'] = 1
|
layer['cycles']['denoising_store_passes'] = 1
|
||||||
layer.use_pass_vector = True`;
|
layer.use_pass_vector = True`;
|
||||||
}
|
}
|
||||||
const command = author.Command("blender-render", {
|
const command = author.Command("blender-render", {
|
||||||
exe: "{blender}",
|
exe: "{blender}",
|
||||||
@ -120,7 +120,7 @@ for layer in bpy.context.scene.view_layers:
|
|||||||
argsBefore: [],
|
argsBefore: [],
|
||||||
blendfile: settings.blendfile,
|
blendfile: settings.blendfile,
|
||||||
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
|
||||||
@ -269,19 +269,19 @@ bpy.ops.render.render(write_still=True)`;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function authorCreateCompositeTask(settings, renderOutput) {
|
function authorCreateCompositeTask(settings, renderOutput) {
|
||||||
let filename;
|
let filename;
|
||||||
let pythonExpression = `
|
let pythonExpression = `
|
||||||
import pathlib
|
import pathlib
|
||||||
import bpy
|
import bpy
|
||||||
C = bpy.context
|
C = bpy.context
|
||||||
basepath = pathlib.Path("${renderOutput}")
|
basepath = pathlib.Path("${renderOutput}")
|
||||||
filename = "MERGED.exr"
|
filename = "MERGED.exr"
|
||||||
`;
|
`;
|
||||||
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
|
||||||
// https://github.com/state-of-the-art/BlendNet/blob/master/BlendNet/script-compose.py#L94
|
// https://github.com/state-of-the-art/BlendNet/blob/master/BlendNet/script-compose.py#L94
|
||||||
pythonExpression += `
|
pythonExpression += `
|
||||||
bpy.ops.image.open(filepath=str(basepath / filename), use_sequence_detection=False)
|
bpy.ops.image.open(filepath=str(basepath / filename), use_sequence_detection=False)
|
||||||
image = bpy.data.images[bpy.path.basename(filename)]
|
image = bpy.data.images[bpy.path.basename(filename)]
|
||||||
image_node = C.scene.node_tree.nodes.new(type='CompositorNodeImage')
|
image_node = C.scene.node_tree.nodes.new(type='CompositorNodeImage')
|
||||||
@ -319,21 +319,21 @@ for node in nodes_to_remove:
|
|||||||
C.scene.node_tree.nodes.remove(node)
|
C.scene.node_tree.nodes.remove(node)
|
||||||
C.scene.render.filepath = str(basepath / "FINAL")
|
C.scene.render.filepath = str(basepath / "FINAL")
|
||||||
bpy.ops.render.render(write_still=True)`;
|
bpy.ops.render.render(write_still=True)`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (settings.format == "OPEN_EXR_MULTILAYER") {
|
if (settings.format == "OPEN_EXR_MULTILAYER") {
|
||||||
// Only rename
|
// Only rename
|
||||||
pythonExpression += `
|
pythonExpression += `
|
||||||
(basepath / filename).rename(basepath / 'FINAL.exr')`;
|
(basepath / filename).rename(basepath / 'FINAL.exr')`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Only export
|
// Only export
|
||||||
pythonExpression += `
|
pythonExpression += `
|
||||||
bpy.ops.image.open(filepath=str(basepath / filename), use_sequence_detection=False)
|
bpy.ops.image.open(filepath=str(basepath / filename), use_sequence_detection=False)
|
||||||
image = bpy.data.images[bpy.path.basename(filename)]
|
image = bpy.data.images[bpy.path.basename(filename)]
|
||||||
image.save_render(str(basepath / "FINAL") + "${settings.image_file_extension}")`;
|
image.save_render(str(basepath / "FINAL") + "${settings.image_file_extension}")`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const task = author.Task(`composite`, "blender");
|
const task = author.Task(`composite`, "blender");
|
||||||
const command = author.Command("blender-render", {
|
const command = author.Command("blender-render", {
|
||||||
exe: "{blender}",
|
exe: "{blender}",
|
||||||
|
Loading…
Reference in New Issue
Block a user