Getting Textures from a material

Forum for OctaneRender Lua scripting examples, discussion and support.
Post Reply
User avatar
MB
Licensed Customer
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.
Contact:

I have the following situation illustrated at end of post.

I am successfully looping through the material pins on a mesh node, identifying there type and getting some information. I was surprised I did not need to do anything specific to tell octane to look for external materials nodes connected to a pin. However I cannot seem to get to the texture file information from any node. Can someone please point me in the right direction. Current routine is included below.

--if node type is glossy
if internalMatNode.type == octane.NT_MAT_GLOSSY then

print (" ")
print("Glossy Material")
print ("----------------------------------")

-- get the diffuse pin values
tblDiffuseValues = internalMatNode:getPinValue(octane.P_DIFFUSE)
print ("Diffuse Pin Values For: " ..internalMatNode.name)
for k, v in pairs(tblDiffuseValues) do
print(k, v)
end

-- if pin has an image, get image file name
-- first determine if another node is attatched

local inputNodeA =internalMatNode:getConnectedNode(octane.P_DIFFUSE)
print ("Glossy input a",inputnodeA)

local inputNodeB =internalMatNode:getConnectedNodeIx(pinIx)
print ("Glossy input b",inputnodeB)

local inputNodeC =internalMatNode:getInputNode(octane.P_SPECULAR)
print ("Glossy input c",inputnodeC)

local inputNodeD =internalMatNode:getInputNodeIx(pinIx)
print ("Glossy input d",inputnodeD)

local inputNodeE =internalMatNode:getOwnedItemIx(pinIx)
print ("Glossy input e",inputnodeE)

local inputNodes =internalMatNode:getInputNodes()

for k, v in pairs(inputNodes) do
print(k, v)
end

-- get the specular pin values
tblSpecularValues = internalMatNode:getPinValue(octane.P_SPECULAR)
print ("Specular Pin Values For: " ..internalMatNode.name)
for k, v in pairs( tblSpecularValues) do
print(k, v)
end
-- if pin has an image, get image file name, check if pin has an inputnode
-- get the opacity pin values
tblOpacityValues = internalMatNode:getPinValue(octane.P_OPACITY)
print ("Opacity Pin Values For: " ..internalMatNode.name)
for k, v in pairs(tblOpacityValues) do
print(k, v)
end
-- if pin has an image, get image file name
-- get the Normal pin values
tblNormalValues = internalMatNode:getPinValue(octane.P_NORMAL)
print ("Normal Pin Values For: " ..internalMatNode.name)
for k, v in pairs(tblNormalValues) do
print(k, v)
end
-- if pin has an image, get image file name
-- get the Bump pin values
tblBumpValues = internalMatNode:getPinValue(octane.P_BUMP)
print ("Bump Pin Values For: " ..internalMatNode.name)
for k, v in pairs(tblBumpValues) do
print(k, v)
end
-- if pin has an image, get image file name
end

thx

mark
Attachments
Texture file nodes.png
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
MB
Licensed Customer
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.
Contact:

After several hours I seem to have this working, so no help required at the moment.
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
roeland
OctaneRender Team
Posts: 1823
Joined: Wed Mar 09, 2011 10:09 pm

For reference this is how you can find out the filename of the image texture used by the material:

Assume we have a material node matNode:

Code: Select all

-- get the node connected to the diffuse pin (skipping linker nodes)
local texNode = matNode:getInputNode("diffuse")
-- assuming T is an image texture node:
local filename = texNode:getAttribute("filename")
By default the diffuse input will have an RGB colour. In that case getPinValue can get the colour directly:

Code: Select all

-- now, assuming we have an RGB colour node:
local rgbColour = matNode:getPinValue("diffuse")
--
Roeland
User avatar
MB
Licensed Customer
Posts: 168
Joined: Tue Jan 15, 2013 3:41 am
Location: Washington, D.C.
Contact:

Roeland,

I wondered when you have a moment if you could explain in more detail the difference between getConnectedNode and getInputNode.

thx

mark
Windows 11, 2x Intel I9, 64GB Ram, 2x GTX 1080 TI, 1 x RTX 380 TI, Oculus Quest 2
User avatar
roeland
OctaneRender Team
Posts: 1823
Joined: Wed Mar 09, 2011 10:09 pm

  • getConnectedNode gives you the node directly connected to an input pin. This may be an input or output node of a graph.
  • getInputNode automatically skips linker nodes
So suppose for instance if you use a liveDB material (which will imported as a node graph) and connect it to a mesh. If you call getConnectedNode it will return the output linker node of that nodegraph. getInputNode returns the actual material node inside the node graph.

--
Roeland
Post Reply

Return to “Lua Scripting”