Page 1 of 8

Render and save to PNG all render targets

PostPosted: Tue Mar 25, 2014 7:39 pm
by smicha
LUA coders,

I need your help. I have about 10 render targets in my scene. Each scene takes about 1h to render. I would love to leave my computer for one night and have all render targets done and saved. Could you please write such LUA script?

smicha

Re: Render and save to PNG all render targets

PostPosted: Sat Mar 29, 2014 7:12 pm
by rosol
Hi
I use this script ( there is 6 rendertargets but you can make more). You should modify project path and path for saved images of course.
I hope I helped

pozdrawiam Piotr

Re: Render and save to PNG all render targets

PostPosted: Sat Mar 29, 2014 7:16 pm
by smicha
Piotrek,

Thank you!

(Wielkie dzięki. Przetestuję i dam znać jak to działa.)

s

Re: Render and save to PNG all render targets

PostPosted: Sat Mar 29, 2014 8:39 pm
by stratified
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

Re: Render and save to PNG all render targets

PostPosted: Sat Mar 29, 2014 8:47 pm
by Tugpsx
Sweet. Thanks

Re: Render and save to PNG all render targets

PostPosted: Sun Mar 30, 2014 8:40 pm
by smicha
Piotrek, Thomas,

Many many thanks!!! This code works like a charm. I hope that we see in the nearest future GUI version of it. Now I can render many rendertargets at once during the night.

Re: Render and save to PNG all render targets

PostPosted: Mon Mar 31, 2014 8:12 pm
by MB
Here it is with a UI

Re: Render and save to PNG all render targets

PostPosted: Tue Apr 01, 2014 12:54 pm
by smicha
Phenomenal work, MB!

My final request to OTOY team - please include this script as a standard script next to daylight animation, turntable,....

Re: Render and save to PNG all render targets

PostPosted: Tue Apr 01, 2014 7:09 pm
by stratified
In the future we'll distribute scripts via the LiveDB as well. We're all working very hard on 2.0 so I don't know if it's going to make it in 2.0 itself.

cheers,
Thomas

Re: Render and save to PNG all render targets

PostPosted: Tue Apr 01, 2014 10:07 pm
by kavorka
Testing it out now!

We got ahead of ourselves and got over 80 separate images ready to render, but manually saving and loading each one takes time (and can't happen while you sleep).

So, I may be putting this script to the test this weekend. It'll be nice getting all those images out and not wasting time swapping them out.