Distributed rendering of single images #104327

Merged
David Zhang merged 22 commits from David-Zhang-10/flamenco:single-image-render into main 2024-09-03 06:47:49 +02:00
Showing only changes of commit 494ffe13a2 - Show all commits

View File

@ -142,6 +142,8 @@ function renderOutputPath(job) {
}); });
} }
// Calculate the borders for the tiles
// Does not take into account the overscan
function calcBorders(tileSizeX, tileSizeY, width, height) { function calcBorders(tileSizeX, tileSizeY, width, height) {
let borders = []; let borders = [];
for (let y = 0; y < height; y += tileSizeY) { for (let y = 0; y < height; y += tileSizeY) {
@ -159,6 +161,7 @@ function authorRenderTasks(settings, renderDir, renderOutput) {
let borders = calcBorders(settings.tile_size_x, settings.tile_size_y, settings.resolution_x, settings.resolution_y); let borders = calcBorders(settings.tile_size_x, settings.tile_size_y, settings.resolution_x, settings.resolution_y);
for (let border of borders) { for (let border of borders) {
const task = author.Task(`render-${border[0]}-${border[1]}`, "blender"); const task = author.Task(`render-${border[0]}-${border[1]}`, "blender");
// Overscan is calculated in this manner to avoid rendering outside the image resolution
let pythonExpr = `import bpy let pythonExpr = `import bpy
scene = bpy.context.scene scene = bpy.context.scene
@ -195,6 +198,16 @@ bpy.ops.render.render(write_still=True)`
function authorMergeTask(settings, renderDir, renderOutput) { function authorMergeTask(settings, renderDir, renderOutput) {
print("authorMergeTask(", renderDir, ")"); print("authorMergeTask(", renderDir, ")");
const task = author.Task("merge", "blender"); const task = author.Task("merge", "blender");
// Burning metadata into the image is done by the compositor for the entire merged image
// The overall logic of the merge is as follows:
// 1. Find out the Render Layers node and to which socket it is connected
// 2. Load image files from the tiles directory.
// Their correct position is determined by their filename.
// 3. Create a node tree that scales, translates and adds the tiles together.
// A simple version of the node tree is linked here:
// https://devtalk.blender.org/uploads/default/original/3X/f/0/f047f221c70955b32e4b455e53453c5df716079e.jpeg
// 4. The final image is then fed into the socket the Render Layers node was connected to.
// This allows the compositing to work as if the image was rendered in one go.
let pythonExpr = `import bpy let pythonExpr = `import bpy
render = bpy.context.scene.render render = bpy.context.scene.render