Hi everybody,
I modified Piotrek's excellent script to work with multiple render targets. It will ask the user for an output directory and render all the render targets in the project to png images (names result_01.png, result_02.png, ...)
- Code: Select all
-- Renders all the available render targets of the loaded project.
-- Ask the user for an output directory and saves all the images into
-- that directory (result_01.png, result_02.png, ...)
--
-- @author Thomas
-- @version 0.1
-- settings used for batch rendering
local settings =
{
["projectPath"] = octane.project.getCurrentProject(),
["renderTargets"] = octane.project.getSceneGraph():findNodes(octane.NT_RENDERTARGET),
["maxSamples"] = 10,
["outputDirectory"] = nil
}
-- no render targets availabe -> error out
if #settings.renderTargets == 0 then
error("no render targets to render in project:", projectPath)
end
-- ask the user for an output directory for the results
local ret = octane.gui.showDialog
{
type = octane.gui.dialogType.FILE_DIALOG,
path = octane.file.getParentDirectory(settings.projectPath),
browseDirectory = true,
save = false,
title = "Select output directory for the render results",
}
if not ret.result or ret.result == "" then
error("no output directory selected")
end
settings.outputDirectory = ret.result
-- loop over all the render targets and render them
for ix, renderTarget in ipairs(settings.renderTargets) do
print(string.format("render project '%s', render target '%s' with %d s/px",
settings.projectPath, renderTarget.name, settings.maxSamples))
-- render the image
octane.render.start
{
renderTargetNode = renderTarget,
maxSamples = settings.maxSamples,
}
-- create an output path for the image
local outImage = string.format("%s/result_%02d.png", settings.outputDirectory, ix)
-- save out the image
octane.render.saveImage(outImage, octane.render.imageType.PNG8)
print("saved out render result:", outImage)
end
If somebody's keen, it would be cool to have a batch render script with a gui to configure max samples, choose and output directory and show the intermediate progress. This is something every Octane customer could benefit from.
cheers,
Thomas