Presets for an OBJ scene ?

Forums: Presets for an OBJ scene ?
Forum for OctaneRender Lua scripting examples, discussion and support.

Presets for an OBJ scene ?

Postby Zay » Wed Jan 01, 2014 7:02 pm

Zay Wed Jan 01, 2014 7:02 pm
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?
Win 11 Pro | i5 12600K | 32GB ram | 2x GTX 1080Ti + 3080Ti - studio driver 546.01| Modo/Blender/ZBrush/Daz/Poser
Zay
Licensed Customer
Licensed Customer
 
Posts: 1116
Joined: Sun Jan 17, 2010 2:53 am

Re: Presets for an OBJ scene ?

Postby Tugpsx » Wed Jan 01, 2014 8:20 pm

Tugpsx Wed Jan 01, 2014 8:20 pm
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.
Dell Win Vista 32 | NVIDIA Quadro NVS135M | Core2 Duo T7500 2.20GHz | 4GB
CyberPowerPC Win 7 64| NVIDIA GTX660Ti (3G) GTX480(1.5G) | 16GB
Tugpsx
Licensed Customer
Licensed Customer
 
Posts: 1145
Joined: Thu Feb 04, 2010 8:04 pm
Location: Chicago, IL

Re: Presets for an OBJ scene ?

Postby Zay » Wed Jan 01, 2014 8:54 pm

Zay Wed Jan 01, 2014 8:54 pm
Yep, that is exactly why I ask for this in Octane standalone and not in a plugin :)
Win 11 Pro | i5 12600K | 32GB ram | 2x GTX 1080Ti + 3080Ti - studio driver 546.01| Modo/Blender/ZBrush/Daz/Poser
Zay
Licensed Customer
Licensed Customer
 
Posts: 1116
Joined: Sun Jan 17, 2010 2:53 am

Re: Presets for an OBJ scene ?

Postby stratified » Wed Jan 01, 2014 9:28 pm

stratified Wed Jan 01, 2014 9:28 pm
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
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Presets for an OBJ scene ?

Postby stratified » Wed Jan 01, 2014 9:32 pm

stratified Wed Jan 01, 2014 9:32 pm
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
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: Presets for an OBJ scene ?

Postby Zay » Wed Jan 01, 2014 9:55 pm

Zay Wed Jan 01, 2014 9:55 pm
Thanks stratified! I'll see what I can do with it :)
Win 11 Pro | i5 12600K | 32GB ram | 2x GTX 1080Ti + 3080Ti - studio driver 546.01| Modo/Blender/ZBrush/Daz/Poser
Zay
Licensed Customer
Licensed Customer
 
Posts: 1116
Joined: Sun Jan 17, 2010 2:53 am

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 9 guests

Fri Apr 19, 2024 1:09 pm [ UTC ]