Render and save to PNG all render targets

Forums: Render and save to PNG all render targets
Forum for OctaneRender Lua scripting examples, discussion and support.

Render and save to PNG all render targets

Postby smicha » Tue Mar 25, 2014 7:39 pm

smicha Tue Mar 25, 2014 7:39 pm
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
Win7, Modo 10.1, Octane for Modo and Sketchup, nVidia latest, TITAN+3x780 6GB, 2600K, P8P67WS, 32GB, 1350W
SMH10, EK, Airplex_480, SR1_560, 20xNB_PL2, 2xD5, Aquaero 6XT
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3145
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Render and save to PNG all render targets

Postby rosol » Sat Mar 29, 2014 7:12 pm

rosol Sat Mar 29, 2014 7:12 pm
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
Attachments
batch2.lua
(2.32 KiB) Downloaded 372 times
rosol
Licensed Customer
Licensed Customer
 
Posts: 4
Joined: Wed Mar 09, 2011 8:17 am

Re: Render and save to PNG all render targets

Postby smicha » Sat Mar 29, 2014 7:16 pm

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

Thank you!

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

s
Win7, Modo 10.1, Octane for Modo and Sketchup, nVidia latest, TITAN+3x780 6GB, 2600K, P8P67WS, 32GB, 1350W
SMH10, EK, Airplex_480, SR1_560, 20xNB_PL2, 2xD5, Aquaero 6XT
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3145
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Render and save to PNG all render targets

Postby stratified » Sat Mar 29, 2014 8:39 pm

stratified Sat Mar 29, 2014 8:39 pm
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
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Render and save to PNG all render targets

Postby Tugpsx » Sat Mar 29, 2014 8:47 pm

Tugpsx Sat Mar 29, 2014 8:47 pm
Sweet. Thanks
Dell Win Vista 32 | NVIDIA Quadro NVS135M | Core2 Duo T7500 2.20GHz | 4GB
CyberPowerPC Win 7 64| NVIDIA GTX660Ti (3G) GTX480(1.5G) | 16GB
Tugpsx
Licensed Customer
Licensed Customer
 
Posts: 1058
Joined: Thu Feb 04, 2010 8:04 pm
Location: Chicago, IL

Re: Render and save to PNG all render targets

Postby smicha » Sun Mar 30, 2014 8:40 pm

smicha Sun Mar 30, 2014 8:40 pm
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.
Win7, Modo 10.1, Octane for Modo and Sketchup, nVidia latest, TITAN+3x780 6GB, 2600K, P8P67WS, 32GB, 1350W
SMH10, EK, Airplex_480, SR1_560, 20xNB_PL2, 2xD5, Aquaero 6XT
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3145
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Render and save to PNG all render targets

Postby MB » Mon Mar 31, 2014 8:12 pm

MB Mon Mar 31, 2014 8:12 pm
Here it is with a UI
Attachments
Batch Output RenderTargets.zip
(2.74 KiB) Downloaded 312 times
Windows 7 Enterprise, 2x Intel Xeon X5650 2.66 GHz, 24GB Ram, GTX 590, Quadro 5000, Quadro K4200
User avatar
MB
Licensed Customer
Licensed Customer
 
Posts: 119
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.

Re: Render and save to PNG all render targets

Postby smicha » Tue Apr 01, 2014 12:54 pm

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

My final request to OTOY team - please include this script as a standard script next to daylight animation, turntable,....
Win7, Modo 10.1, Octane for Modo and Sketchup, nVidia latest, TITAN+3x780 6GB, 2600K, P8P67WS, 32GB, 1350W
SMH10, EK, Airplex_480, SR1_560, 20xNB_PL2, 2xD5, Aquaero 6XT
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3145
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Render and save to PNG all render targets

Postby stratified » Tue Apr 01, 2014 7:09 pm

stratified Tue Apr 01, 2014 7:09 pm
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
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Render and save to PNG all render targets

Postby kavorka » Tue Apr 01, 2014 10:07 pm

kavorka Tue Apr 01, 2014 10:07 pm
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.
Intel quad core i5 @ 4.0 ghz | 8 gigs of Ram | Geforce GTX 470 - 1.25 gigs of Ram
kavorka
Licensed Customer
Licensed Customer
 
Posts: 1351
Joined: Sat Feb 04, 2012 6:40 am
Next

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 2 guests

Thu Nov 21, 2019 1:22 am [ UTC ]