Lua script rendering verbosity in stdout or stderr

Forums: Lua script rendering verbosity in stdout or stderr
Forum for OctaneRender Lua scripting examples, discussion and support.

Lua script rendering verbosity in stdout or stderr

Postby ptunstall » Tue Dec 03, 2019 5:48 pm

ptunstall Tue Dec 03, 2019 5:48 pm
I am new to lua scripting/octane api. I have been trying to find the proper way to get more render statistics/verbosity to print to stdout or stderr via script. I took the code below from the batch rendering script and was hoping I could modify it with flags to get more output. I saw the statisticsCallback in PROPS_RENDER_START, but I am just too new to lua and the api to get the syntax correct. Any help is appreciated.
Code: Select all
                            if not skipFrame then
                                octane.render.start
                                {
                                    renderTargetNode = renderTarget.node,
                                    callback         = function()
                                        if gSettings.cancelled then
                                            octane.render.callbackStop()
                                        end
                                    end
                                }
                            end
ptunstall
Licensed Customer
Licensed Customer
 
Posts: 131
Joined: Thu Jun 04, 2015 1:36 am

Re: Lua script rendering verbosity in stdout or stderr

Postby jobigoud » Tue Dec 03, 2019 7:09 pm

jobigoud Tue Dec 03, 2019 7:09 pm
You can use `print()` to write the value of properties to the output in the script editor window or to the log viewer if used as a global script or in a scripted graph. (You can set up the Octane workspace so the API browser and log viewer are always visible).

Here is a test script, you can paste it in the script editor of a test scene and play with it. I have flattened the callbacks functions.

Code: Select all
-- Look for a node.
local rootGraph = octane.project.getSceneGraph()
local items = rootGraph:findItemsByName("Render target", true)
local nodeRenderTarget = items[1]

-- Callback called by the renderer, passing intermediate render results.
-- The current result is passed in as a PROPS_RENDER_RESULT.
local function renderCallback(propsRenderResult)

    print("In render callback")
    print("\tsamples: " .. propsRenderResult.samples)

    -- TODO: Test if cancelled, call octane.render.callbackStop().
end

-- Callback called by the renderer, passing intermediate render statistics.
-- The current statistics are passed in as a PROPS_RENDER_RESULT_STATISTICS.
local function statisticsCallback(propsRenderResultStatistics)

    print("In statistics callback")
    print("\tbeautySamplesPerSecond: " .. propsRenderResultStatistics.beautySamplesPerSecond)
    print("\trenderTime: " .. propsRenderResultStatistics.renderTime)
    print("\testimatedRenderTime: " .. propsRenderResultStatistics.estimatedRenderTime)

end

-- Properties to start the render. See octane.render.PROPS_RENDER_START.
local propsRenderStart = {
    callback = renderCallback,
    doUpdate = true,
    maxRenderTime = 2,
    renderTargetNode = nodeRenderTarget,
    restart = true,
    statisticsCallback = statisticsCallback
}

-- Start rendering.
local result = octane.render.start(propsRenderStart)

print("Render finished.")
print("\trenderTime" .. result.renderTime)
User avatar
jobigoud
OctaneRender Team
OctaneRender Team
 
Posts: 33
Joined: Sat Aug 15, 2015 1:28 pm

Re: Lua script rendering verbosity in stdout or stderr

Postby ptunstall » Tue Dec 03, 2019 8:40 pm

ptunstall Tue Dec 03, 2019 8:40 pm
Exactly what I needed! Thanks!
ptunstall
Licensed Customer
Licensed Customer
 
Posts: 131
Joined: Thu Jun 04, 2015 1:36 am

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 2 guests

Sat Dec 14, 2019 5:22 am [ UTC ]