Page 1 of 1
Presets for an OBJ scene ?
Posted: Wed Jan 01, 2014 7:02 pm
by Zay
Is it possible to edit the materials from a loaded OBJ file using Lua? Making your own presets to correct most problems when loading a raw OBJ? I would really like to see an example I can work with if this is possible
Examine the OBJ file and change all Diffuse materials to Glossy.
Set the Specular/GreyScale Color to a fixed value.
Set the Roughness/GreyScale Color to a fixed value.
Set the Bump/GreyScale Color Power (if a node is found) to a fixed value.
Set the Index/Float Value to a fixed value.
Would this be possible?
Re: Presets for an OBJ scene ?
Posted: Wed Jan 01, 2014 8:20 pm
by Tugpsx
What program are you generating the OBJ files from. There are several Plugins and exporters that already do this, that's why i'm curious. For instance some exporters modifies the mtl file to add options that work in Octane, while the new version of Octane now supports custom ocs file.
Re: Presets for an OBJ scene ?
Posted: Wed Jan 01, 2014 8:54 pm
by Zay
Yep, that is exactly why I ask for this in Octane standalone and not in a plugin

Re: Presets for an OBJ scene ?
Posted: Wed Jan 01, 2014 9:28 pm
by stratified
Hi Zay,
Here's a basic skeleton script, all it does is collect all the materials in the mesh node in a list. What you do with them is up to you... .
Code: Select all
-- Script to do "something" with the materials of a loaded OBJ mesh.
-- Get the selected mesh.
local mesh = octane.project.getSelection()[1]
assert(mesh:getProperties().type == octane.NT_GEO_MESH, "mesh expected")
-- Get all the materials of the selected mesh.
local mats = {}
for pinIx = 1, mesh:getPinCount() do
local matNode = mesh:getConnectedNodeIx(pinIx)
if matNode then
print(string.format("pin %d -> material %s", pinIx, matNode:getProperties().name))
-- collect the connected nodes
table.insert(mats, matNode)
end
end
-- We have the materials in a list, do something with them ...
For example, you could write a script that ask the user which OBJ file to load and display a window with some presets that can be configured. When the mesh is loaded, those presets will be used (e.g. create glossy materials for materials slots that weren't loaded, set the roughness to 1, ...).
I hope this snippet helps...
cheers,
Thomas
Re: Presets for an OBJ scene ?
Posted: Wed Jan 01, 2014 9:32 pm
by stratified
BTW, you could make it even more funky by asking the user which OBJ to load and then do the magic automatically.
Here we describe how you would load an OBJ file from Lua
http://render.otoy.com/forum/viewtopic.php?f=73&t=37294
cheers,
Thomas
Re: Presets for an OBJ scene ?
Posted: Wed Jan 01, 2014 9:55 pm
by Zay
Thanks stratified! I'll see what I can do with it
