Page 1 of 1
Rendertarget always returns an attatched kernel
Posted: Wed Apr 09, 2014 4:54 pm
by MB
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
Re: Rendertarget always returns an attatched kernel
Posted: Wed Apr 09, 2014 6:38 pm
by stratified
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
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
Re: Rendertarget always returns an attatched kernel
Posted: Wed Apr 09, 2014 9:47 pm
by MB
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
Re: Rendertarget always returns an attatched kernel
Posted: Thu Apr 10, 2014 12:01 am
by stratified
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

that must have been a painfull experience. Notepad++ is an excellent step up.
cheers,
Thomas
Re: Rendertarget always returns an attatched kernel
Posted: Thu Apr 10, 2014 12:09 am
by MB
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
Re: Rendertarget always returns an attatched kernel
Posted: Thu Apr 10, 2014 12:52 am
by stratified
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).
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
Re: Rendertarget always returns an attatched kernel
Posted: Thu Apr 10, 2014 2:33 am
by MB
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