Rendertarget always returns an attatched kernel

Forum for OctaneRender Lua scripting examples, discussion and support.
Post Reply
User avatar
MB
Licensed Customer
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.
Contact:

Thomas,

I am looking into implementing a test in the batch render to see if a kernel is attatched to a render target, and if so use its max samples value instead of the value in the numeric box control.
However this code always finds a kernel node even when one is not attatched. Any advise would be appreciated.

Code: Select all

 local Kernel = renderTarget:getConnectedNode(octane.P_KERNEL)
        showDebugInfo(Kernel, "Kernel info")
        
        if Kernel ~= nil then
        
            if Kernel:getProperties().type == octane.NT_KERN_DIRECTLIGHTING
            or Kernel:getProperties().type == octane.NT_KERN_PATHTRACING 
            or Kernel:getProperties().type == octane.NT_KERN_PMC
            or Kernel:getProperties().type == octane.NT_KERN_INFO
            or Kernel:getProperties().type == octane.NT_KERN_MATPREVIEW 
            then
            
                showDebugInfo(Kernel:getProperties().type, "A known 'Kernel' is conncted to the render target")
                -- Get the max samples from the kernel
                
            else
            
                showDebugInfo(Kernel:getProperties().type, "An unknown 'Kernel' is conncted to the render target")
                
            end

        end


function showDebugInfo(text,msg)

 	local ret = octane.gui.showDialog

		{
            type  = octane.gui.dialogType.BUTTON_DIALOG,
			buttonTexts =  {"Continue"}, 
	        icon  = octane.gui.dialogIcon.WARNING,
            title = "DebugInfo for: "..tostring(text),
            text  = tostring(msg),
		}
        
		-- 1 for first button, 2 for second button
		return ret.result
        
end
thx

Mark
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
stratified
OctaneRender Team
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Hey Mark,

I think your code is fine. Could it be that you are confusing an internal kernel node (filled kernel pin circle) with an unconnected node (unfilled kernel pin circle)? Here are some examples (orbx file is attached):
kernel node test cases
kernel node test cases
Here's a small test script, just select a rendertarget and run it. Note that you have to modify getConnectedNode to getInputNode or the rightmost test case wouldn't work correctly - the script would find the output linker node but this isn't a kernel node.

Code: Select all

-- selected render target
local renderTargetNode = octane.project.getSelection()[1]

-- use getInputNode instead of getConnectedNode (this way we kan skip linker nodes)
local kernelNode = renderTargetNode:getInputNode(octane.P_KERNEL)

print(kernelNode)

-- figure out the type of kernel (you can use .type here)
if kernelNode ~= nil then
    if kernelNode.type == octane.NT_KERN_DIRECTLIGHTING
    or kernelNode.type == octane.NT_KERN_PATHTRACING 
    or kernelNode.type == octane.NT_KERN_PMC
    or kernelNode.type == octane.NT_KERN_INFO
    or kernelNode.type == octane.NT_KERN_MATPREVIEW 
    then
        print(string.format("kernel with %d samples/px",
                            kernelNode:getPinValue(octane.P_MAX_SAMPLES)))
    else
        print("unknown kernel", kernelNode.type)
    end
else
    print("no kernel node connected to the render target")
end
I hope this helps...

cheers,
Thomas
Attachments
kernel-node-test.orbx
project with the 3 test cases
(81.7 KiB) Downloaded 291 times
kernel-test.lua
example test script
(892 Bytes) Downloaded 287 times
User avatar
MB
Licensed Customer
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.
Contact:

Thomas, (others, don't bother downloading this script, its broken)

that worked, thankyou , but it seems to have triggered something else that i don't understand, prior to implementing this feature the actual rendering code

Code: Select all

            octane.render.start
            { 
                renderTargetNode = renderTarget,
                maxSamples       = ms,
            }
worked fine in all circumstances. Now it throws and error at this point "no kernel node connected to render target". Its weird because it seems like it might run once, but then if you connect and disconnect a kernal to the rendertarget it triggers this error for future runs. Something must change in ternally that i don't know how to handle.

I am including the full script for you to run. It is a modification of your last post.
modifications include;
a) an attempt to add a pause and continue feature, i can get it to pause, but not continue, i don't believe i am doing this inside a callback so i'm not sure what is going on.
b) the generation of a log file with more stats about each rendering ( still want to capture more stats about critical settings ).
c) minor changes to wording of the UI


I have stopped writting scripts in pure notepad and upgraded to notepad++ so hopefully tabs are working better for you.

best

Mark
Attachments
batch_render.lua
(19.84 KiB) Downloaded 290 times
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
stratified
OctaneRender Team
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Hi Mark,

You always need to have a kernel node connected to the rendertarget when using it in octane.render.start. This is a limitation but we might relax that in the future.

You can only pause renders that where started before the Lua script was started. You should implement pausing by stopping the current render target and then restart with that one when the continue button is clicked.

Wow, you where using notepad :shock: that must have been a painfull experience. Notepad++ is an excellent step up.

cheers,
Thomas
User avatar
MB
Licensed Customer
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.
Contact:

Thomas

so if i understand it correctly,
when u add a render target to the scene, there is an implied kernel from somewhere (preview configuration) hence the above code works, if i then connect a kernel and remove it, the render target truly has no kernel and the above code will not work.

What do u think from a users point of view is the right way to handle this. Force all render targets to have a kernel?
I don't see a way in code to test which ones would work without and which ones need to have a kernel reconnected.

thanks
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
stratified
OctaneRender Team
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Hi Mark,

When you add a render target (the left in below picture) it just has a kernel node that's internal to the pin. There's no implied render target or something, it's just a connected node but internal. The preview configuration has nothing to do with this. It's the config we use for the "material ball" (pre 1.50, this node was explicitely there).
render_targets.png
It doesn't make sense to have a render target without a kernel (it will default to the wireframe kernel). Probably my wording was a bit misleading in the previous post. The code can safely assume that each render target has a kernel connected to it. To be safe we could filter out the render targets that don't have a kernel in the beginning of the script:

Code: Select all

-- filter out render targets with no kernel
local filtered = {}
for ix, renderTargetNode in ipairs(settings.renderTargets) do
    if renderTargetNode:getInputNode(octane.P_KERNEL) ~= nil then
        table.insert(filtered, renderTargetNode) 
    end
end
settings.renderTargets = filtered
As an alternative you could skip the render targets that don't have a kernel when rendering. To render with octane.render.start they always need a kernel.

cheers,
Thomas
User avatar
MB
Licensed Customer
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.
Contact:

Thomas,

i think i get it then...

all new render targets have an internal kernel node, however this can be lost by attatching and then detaching an external kernel node, and then octane.render.start ceases to work.

it seems to me that detaching an external kernel, should either, leave an internal copy of that in the render target, or it should internally default back to what it was when it was first created, as a policy i'm not sure which, but probabaly the latter.

I think i can trap all situations now, i guess i will warn/ask the user to attach an external kernel to those that have lost them if they don't want the rendertarget to be ignored in the batch process, else ignore.

best
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
Post Reply

Return to “Lua Scripting”