Copy material from mesh pin to new material node?

Forums: Copy material from mesh pin to new material node?
Forum for OctaneRender Lua scripting examples, discussion and support.

Re: Copy material from mesh pin to new material node?

Postby Wallan » Fri May 15, 2015 5:24 pm

Wallan Fri May 15, 2015 5:24 pm
Here is a picture of what the code does so far.
Hopefully that answers any remaining questions in what I tried to accomplish.

The specular nodes are just diffuse nodes with faked names so far.
The last step, to really make them specular nodes still remains.
Thank's to your sample code I feel confident about making it work :)

Regards
Wallan

Image
Windows 7 Ultimate 64bit 32Gb RAM. Intel Core i7-5820K [email protected] GHZ. Display uses a Gigabyte GTX 460 1Gb VRAM. Octane uses an EVGA GTX 970 4Gb VRAM.
Wallan
Licensed Customer
Licensed Customer
 
Posts: 47
Joined: Fri Jan 23, 2015 6:13 pm

Re: Copy material from mesh pin to new material node?

Postby Wallan » Fri May 15, 2015 10:27 pm

Wallan Fri May 15, 2015 10:27 pm
Code: Select all
-- Copies the content of the diffuse pin of the diffuse material into the transmission pin
-- of the specular material.

-- create materials
local diffuseMatNode = octane.node.create{ type = octane.NT_MAT_DIFFUSE, name = "source node" }
local texNode        = octane.node.create{ type = octane.NT_TEX_CHECKS, "checkers" }
diffuseMatNode:connectTo(octane.P_DIFFUSE, texNode)
local specularMatNode = octane.node.create{ type = octane.NT_MAT_SPECULAR, name = "dest. node" }

-- wrap up the full tree connect to the diffuse pin in a seperate nodegraph and make sure that
-- this graph has a texture output node
local tmpGraph = octane.nodegraph.create{ type = octane.GT_STANDARD, name = "Mess wrapper" }
local matOutputNode = octane.node.create{ type = octane.NT_OUT_TEXTURE, graphOwner = tmpGraph, name = "texture output" }
local copy = tmpGraph:copyItemTree(texNode)
matOutputNode:connectTo(octane.P_INPUT, copy)

-- copy the full graph into the transmission pin of the specular material
specularMatNode:copyFrom(octane.P_TRANSMISSION, tmpGraph)

-- tidy up
octane.project.getSceneGraph():unfold()


In your example you copy the texNode.
But, in your case that is a reference to the node created before.

In my case I don't create that node from code so I don't have direct access to it.
I guess I have to get it from the diffuse pin in the material somehow or?
Windows 7 Ultimate 64bit 32Gb RAM. Intel Core i7-5820K [email protected] GHZ. Display uses a Gigabyte GTX 460 1Gb VRAM. Octane uses an EVGA GTX 970 4Gb VRAM.
Wallan
Licensed Customer
Licensed Customer
 
Posts: 47
Joined: Fri Jan 23, 2015 6:13 pm

Re: Copy material from mesh pin to new material node?

Postby stratified » Sat May 16, 2015 4:50 am

stratified Sat May 16, 2015 4:50 am
Wallan wrote:
Code: Select all
-- Copies the content of the diffuse pin of the diffuse material into the transmission pin
-- of the specular material.

-- create materials
local diffuseMatNode = octane.node.create{ type = octane.NT_MAT_DIFFUSE, name = "source node" }
local texNode        = octane.node.create{ type = octane.NT_TEX_CHECKS, "checkers" }
diffuseMatNode:connectTo(octane.P_DIFFUSE, texNode)
local specularMatNode = octane.node.create{ type = octane.NT_MAT_SPECULAR, name = "dest. node" }

-- wrap up the full tree connect to the diffuse pin in a seperate nodegraph and make sure that
-- this graph has a texture output node
local tmpGraph = octane.nodegraph.create{ type = octane.GT_STANDARD, name = "Mess wrapper" }
local matOutputNode = octane.node.create{ type = octane.NT_OUT_TEXTURE, graphOwner = tmpGraph, name = "texture output" }
local copy = tmpGraph:copyItemTree(texNode)
matOutputNode:connectTo(octane.P_INPUT, copy)

-- copy the full graph into the transmission pin of the specular material
specularMatNode:copyFrom(octane.P_TRANSMISSION, tmpGraph)

-- tidy up
octane.project.getSceneGraph():unfold()


In your example you copy the texNode.
But, in your case that is a reference to the node created before.

In my case I don't create that node from code so I don't have direct access to it.
I guess I have to get it from the diffuse pin in the material somehow or?


You can access the input node via diffuseMaterialNode:getInputNode(octane.P_DIFFUSE).

cheers,
Thomas
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Copy material from mesh pin to new material node?

Postby Wallan » Sat May 16, 2015 12:42 pm

Wallan Sat May 16, 2015 12:42 pm
:)

Progressing fine so far.
Was thinking about changing all diffuse to specular as it gives som more control to shininess.

Does Octane not import specular maps?

Another small problem, how do I check if something exists before i destroy it.
Windows 7 Ultimate 64bit 32Gb RAM. Intel Core i7-5820K [email protected] GHZ. Display uses a Gigabyte GTX 460 1Gb VRAM. Octane uses an EVGA GTX 970 4Gb VRAM.
Wallan
Licensed Customer
Licensed Customer
 
Posts: 47
Joined: Fri Jan 23, 2015 6:13 pm
Previous

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 1 guest

Sat Jul 20, 2019 3:17 am [ UTC ]