But I come with what might be a bug? I unfortunately realized there is 1) no straight forward way of executing the Lua script I've been working on from Unity C#, and 2) there doesn't appear to be a good way for me to be able to get the information I need (given my constraints) to the octane nodes. So I am attempting to replicate the general functionality of my Lua script by using the Unity C# API. I've hit a major snag though.
Below I have my Lua script, my C# code snippet and a screenshot of the Node graph. In my script I start at the RenderTarget node and make my way to a geoGroup in the scene (our container for ALL geometry in the scene). From there I loop through all of the inputNodes for the geoGroup and attempt to grab the Object Layer Node supposedly attached to the inputNode's P_GEOMETRY pin. But I can't.
I've been using the Node.Select() method to make sure I'm getting where I need, as well as debugging Node.Type, and Node.Name to double-triple check. But nothing. My Select() always stops at the inputNode. Even if I call Select on the node that is the supposed result of inputNode.GetConnectedNode(<pin>). I have also tried both overloads of the GetConnectedNode() call, supplying both "geometry" and PinId.P_GEOMETRY. Nothing. I was hoping you might be able to provide some insight into why this is, and if there is any alternative method for getting to those material map nodes from C#.
This is all made doubly confusing by the fact that I have to go through a similarly typed NT_GEO_PLACEMENT node to even get to the scene's geoGroup, and that works perfectly well. Many thanks in advance. As always, please let me know if there is any other information I can provide.
EDIT: Further investigation has yielded some more information that may be useful in this thread. If i hit the 'Render' button on the PBR Render Target Component, the plugin with automatically digest the scene and create a node graph like the one I've described and attempted to traverse above. I cannot traverse if I do this. HOWEVER, if i go into the node graph, and manually create a new input for the geoGroup, a new Geometry->Placement node, and a new Geometry->Object Layer Map node, and hook it all up by hand, then i can indeed run my C# script and gain access to the elusive Object Layer Map node. So there is seemingly something in the auto scene graph creation that is messed up and not creating the proper references beyond a certain point.
Unity v2019.2.5f1
Octane plugin v2019.1 (6000100)
renderer v1.2.0.1376
Lua script:
- Code: Select all
graph = octane.project.getSceneGraph()
nodes = octane.nodegraph.findNodes(graph, octane.NT_MAT_MAP, true);
for mm,matMap in ipairs(nodes) do
print(matMap)
for mmp,matMapPin in pairs(matMap.pinNames) do
connectedInput = matMap:getConnectedNode(matMapPin)
if(connectedInput.type == octane.NT_OUT_MATERIAL) then
materialGraph = connectedInput.graphOwner
for mgi,matGraphInput in pairs(materialGraph:getInputNodes()) do
if(matGraphInput.name == "_BumpMap" or matGraphInput.name == "_DetailNormalMap") then
imageTex = matGraphInput:getConnectedNode(octane.P_INPUT)
imageTex:setPinValue(octane.P_INVERT, true)
end
end
end
end
end
C# script:
- Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OctaneUnity;
using Octane;
using OctanePlugin;
using UnityEditor;
public class OctaneMaterialTest : MonoBehaviour
{
public MeshRenderer vcn;
[ContextMenu("Find Material")]
public void FindMaterialWithVCN()
{
PBRRenderTargetComponent rtc = FindObjectOfType<PBRRenderTargetComponent>();
rtc.RenderTarget.Select();
Node placement = rtc.RenderTarget.GetConnectedNode(PinId.P_MESH);
Node geoOut = placement.GetConnectedNode("geometry");
Node geoGroup = geoOut.GetConnectedNode(PinId.P_INPUT);
for(uint n = 0; n < geoGroup.PinCount; n++)
{
Node inputNode = geoGroup.GetConnectedNodeIx(n);
if(inputNode){
Node objectLayer = inputNode.GetConnectedNode(PinId.P_GEOMETRY);
/// This should be the Object Layer Node shown in the screen shot.
/// but it always returns the same node as inputNode
objectLayer.Select();
}
}
}
}