How to properly grab Node Graphs on Material Mappers

Forum for OctaneRender Lua scripting examples, discussion and support.
Post Reply
jpetty7317
Posts: 15
Joined: Fri Sep 20, 2019 1:32 pm

Hi there,

As the title suggests, my question here is pretty straight forward. And I have a screenshot attached to show you what I'm getting after.

I'm dealing with materials that are created on the fly and mapped into Octane Materials via the Unity Standard shader. In doing so, the nodes seem to get set up as shown in my screenshot. A Geometry and a series of Node Graphs get fed, as input, into a Material Mapper node. All of that makes sense. But, I need to be able to get to the Node Graph inputs for the Material Mapper so I can tweak values on them. Nothing I have tried appears to work for me. Below is a code snippet that got me 'closest'. Any suggestions you might have are greatly appreciated. Thank you in advance.

Code: Select all

-- I have tried this.
nodes = octane.nodegraph.findNodes(octane.project.getSceneGraph(), octane.NT_MAT_MAP, true);
for i,entry in ipairs(nodes) do
    print(entry)
    for s=1,entry.pinCount do
            print(octane.node.getPinValueIx(entry,s))
    end
end

-- I have also tried this
nodes = octane.nodegraph.findNodes(octane.project.getSceneGraph(), octane.NT_MAT_MAP, true);
for i,entry in ipairs(nodes) do
    print(entry)
    for n,name in pairs(entry.pinNames) do -- have tried with ipairs and pairs
            print(octane.node.getPinValue(entry,name))
    end
end
The error I get back is as follows "[string "test.lua"]:15: Cannot get connected attribute via pin.". I feel like this should be a pretty trivial task, but the whole thing has given me quite a headache. Please let me know if there is any more information I can provide to help in resolving this!

Unity version 2019.2.5f1
Octane version 2019.1 (6000100)
renderer version 1.2.0.1376

Image
User avatar
jobigoud
OctaneRender Team
Posts: 247
Joined: Sat Aug 15, 2015 1:28 pm

Try to use `node.getConnectedNodeIx` instead of `node.getPinValueIx`.
getPinValue is a shortcut for when you know that the connected node is a "value node", that is, a node like a float, bool, int, etc. that has a single A_VALUE attribute, and the function lets you directly get the value inside the node with just one call, for convenience.
In your case you need to grab the material nodegraphs as proper node objects and work from there.
jpetty7317
Posts: 15
Joined: Fri Sep 20, 2019 1:32 pm

Thanks much! This did the trick. I was able to grab the NT_OUT_MATERIAL nodes in each of the graphs using ConnectedNode like you suggested and was then able to grab the graphOwner of that that output node. From there I could grab all of the pins and inputs!
gah5118
Licensed Customer
Posts: 358
Joined: Thu Jun 02, 2011 4:25 pm

jpetty7317 wrote:Thanks much! This did the trick. I was able to grab the NT_OUT_MATERIAL nodes in each of the graphs using ConnectedNode like you suggested and was then able to grab the graphOwner of that that output node. From there I could grab all of the pins and inputs!
can you post your updated code? I think this might be similar to what I'm trying to figure out.
Windows 8.1 | i7 950 | GTX 780ti | 24gb ddr3
Post Reply

Return to “Lua Scripting”