Material linker

Forums: Material linker
Forum for OctaneRender Lua scripting examples, discussion and support.

Material linker

Postby lance_uppercut » Mon Sep 10, 2018 10:54 pm

lance_uppercut Mon Sep 10, 2018 10:54 pm
Hi,

I'm sharing a script that I wrote to help deal with the large number of materials and meshes I have in my architectural scenes. I used to spend a lot of time connecting pins to each other for every new mesh in my scene, and it was tedious especially with so many lines covering the scene graph. This script runs through all the material input pins of the selected meshes, and matches them to material output pins that reside inside a separate node graph where I have all my materials. Here's how it's used:

Inside your materials node graph, the output pins should be named to match the material names that come in with your mesh. (I work in Sketchup and bring in OBJ files)
MaterialsLinker_NodeGraph.jpg


Select at least one mesh, and ONE node graph with the materials.
MaterialsLinker_Selection.jpg


Run the script (shortcut is ALT-L) and all names that match will be linked up.
MaterialsLinker_Linked.jpg


One more thing to note, there is a variable at the top of the lua file that goes:

local copy_materials = false
change this to
local copy_materials = true
and the script will COPY the materials rather than linking them. This will NOT copy any material input nodes, like diffuse textures, that are expanded out of the material. To get them to copy over, you have to collapse these other nodes into the material node. Roeland's script Move Nodes into Node Pins can help with this:
https://render.otoy.com/forum/viewtopic.php?f=73&t=54108
Attachments
MaterialsLinker.lua
(3.5 KiB) Downloaded 65 times
lance_uppercut
Licensed Customer
Licensed Customer
 
Posts: 4
Joined: Fri Jan 23, 2015 12:51 am
Location: Toronto, Canada

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 1 guest

Thu Jun 20, 2019 1:26 am [ UTC ]