Referenced material

Forum for OctaneRender Lua scripting examples, discussion and support.
Post Reply
manalokos
Licensed Customer
Posts: 441
Joined: Fri Nov 18, 2011 4:43 pm

Hello

I would like to know if it would be possible with LUA to create a scripted graph that generates a material that is an instance of an existing material (group)
and that updates in parallel with any changes you might do the original material?

This would be a solution to a problem that we usually have, as sometimes we have much more objects than materials, and to connect via nodes a material to several geometries
can be complicated.
The best would be to have this possibility natively in Octane Standalone, where you could choose Material#23
and it would use the material connected to the port #23 of a "material master node", this would allow to change a specific material in all the scene, in all the geometries at once.


Kind regards
Filipe
User avatar
jobigoud
OctaneRender Team
Posts: 247
Joined: Sat Aug 15, 2015 1:28 pm

Hi,
I made a small prototype script to see if this could work. See if it works for your use-case.

It will look for materials nodes with the same name and type as the reference material you plug into the script and try to keep them in sync with it.

Please backup the scene before testing, I can't guarantee that it won't crash, destroy the wrong node, etc. Do let me know of any issue. In order to replicate the reference material, including textures and everything that could be attached to it, it needs to duplicate the entire node tree of the reference. This should work but it might be costly and if the reference material has expanded nodes they will be created at the original location which will make the whole graph weird.
Attachments
entangled-material.orbx
(105.12 KiB) Downloaded 275 times
entangledMaterial.lua
(2.47 KiB) Downloaded 269 times
manalokos
Licensed Customer
Posts: 441
Joined: Fri Nov 18, 2011 4:43 pm

Hello jobigoud!

Thank you so much!
I gave it a try and I can confirm that it works pretty well for simple materials, but if you have a more complex material inside a nodegraph group with a material output, add a texture, or change connections it does not work that well... but it can be used for small tweaks in a pre-assembled material, but it will be messy since it can't be inside a group.

I am not sure that doing this by scripting will ever be stable enough, what do you think?
Maybe if it was the instanced materials that had a scripted operator that would fetch a Nodegraph with a specific name, and copy it and connect to it?

Kind regards
Filipe
Post Reply

Return to “Lua Scripting”