local MyGraphScript = {} -- variables declared in the script scope are visible for all functions in our -- script for as long as the scripted graph is not deleted or reloaded (in -- programming terms, our two functions become "closures"). local inputs,outputs, tex -- onInit function, this is called once in the beginning. function MyGraphScript.onInit(self, graph) -- input and output infos local inputInfos = { {type=octane.PT_TEXTURE, label="Texture", defaultNodeType=octane.NT_TEX_IMAGE}, {type=octane.PT_TRANSFORM, label="Transform", defaultNodeType=octane.NT_TRANSFORM_VALUE} } local outputInfos = { {type=octane.PT_TEXTURE, label="Texture"}, {type=octane.PT_TEXTURE, label="TextureWithOffset"} } -- use these functions to set up input and output linkers. This will keep -- existing linkers so existing connections in the parent graph are kept. inputs = graph:setInputLinkers(inputInfos) outputs = graph:setOutputLinkers(outputInfos) -- set up a node to give the graph some output value --tex = octane.node.create{ type=octane.NT_TEX_IMAGE, name="localTexture", graphOwner=graph } --outputs[1]:connectTo("input", tex) local inTex = inputs[1]:getConnectedNode(octane.P_INPUT) local Tex1 = octane.nodegraph.copyItemTree(graph, inTex) local Tex2 = octane.nodegraph.copyItemTree(graph, inTex) local inUV = inputs[2]:getConnectedNode(octane.P_INPUT) local UV2 = octane.nodegraph.copyItemTree(graph, inUV) Tex2:connectTo(octane.P_TRANSFORM, UV2) outputs[1]:connectTo(octane.P_INPUT, Tex1) outputs[2]:connectTo(octane.P_INPUT, Tex2) end -- this function is called every time the value of an input linker changes function MyGraphScript.onEvaluate(self, graph) local inTex = inputs[1]:getConnectedNode(octane.P_INPUT) local Tex2 = octane.nodegraph.copyItemTree(graph, inTex) local inUV = inputs[2]:getConnectedNode(octane.P_INPUT) local UV2 = octane.nodegraph.copyItemTree(graph, inUV) Tex2:connectTo(octane.P_TRANSFORM, UV2) outputs[2]:connectTo(octane.P_INPUT, Tex2) end -- In lua, a script is run as if the script defines a function body, so -- like in a function you may return a value return MyGraphScript