How to properly grab Node Graphs on Material Mappers

Forums: How to properly grab Node Graphs on Material Mappers
Forum for OctaneRender Lua scripting examples, discussion and support.

How to properly grab Node Graphs on Material Mappers

Postby jpetty7317 » Tue Sep 24, 2019 4:57 am

jpetty7317 Tue Sep 24, 2019 4:57 am
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
jpetty7317
 
Posts: 15
Joined: Fri Sep 20, 2019 1:32 pm

Re: How to properly grab Node Graphs on Material Mappers

Postby jobigoud » Wed Sep 25, 2019 7:52 am

jobigoud Wed Sep 25, 2019 7:52 am
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.
User avatar
jobigoud
OctaneRender Team
OctaneRender Team
 
Posts: 23
Joined: Sat Aug 15, 2015 1:28 pm

Re: How to properly grab Node Graphs on Material Mappers

Postby jpetty7317 » Wed Sep 25, 2019 2:56 pm

jpetty7317 Wed Sep 25, 2019 2:56 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!
jpetty7317
 
Posts: 15
Joined: Fri Sep 20, 2019 1:32 pm

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 1 guest

Wed Nov 13, 2019 3:02 pm [ UTC ]