Baking Graph with Lua

Forums: Baking Graph with Lua
Forum for OctaneRender Lua scripting examples, discussion and support.

Baking Graph with Lua

Postby bepeg4d » Wed Jan 06, 2016 10:35 am

bepeg4d Wed Jan 06, 2016 10:35 am
Hi all,

here is a Lua script to speed up the baking process with OctaneRender v3/4.

- new update to work also with v4:
BakingGraph_4.lua
(16.58 KiB) Downloaded 12 times


-old versions-
Little update to metch to the new OctaneRender™ v3 aplha 4 version with displacement enabled during Baking:
BackingGraph_2.0.lua
(8.5 KiB) Downloaded 260 times

For OctaneRender v3 Alpha 3 or below, please continue to use the old 1.9 version:
BackingGraph_1.9.lua
(9.07 KiB) Downloaded 255 times


The idea is to select an obj mesh node and the render target already set up previously and then run the script. The result should be a new node graph with all the necessary copies of the original nodes to automate the baking process, in this way the original scene is not touched and we can adapt the nodes, for example disabling any displacement node in the materials since is not currently supported by the baking feature. For every pin material of the mesh node, the script generate an object layer node and a new render target with a specific baking camera with proper attributes.
If the script is opened in the Script Editor window, almost on top, it is possible to change some default values for the baking cameras, then, if the script is saved, it can be execute directly from the script menu with the desired default values.
baking_graph_default_settings.jpg

After the script has been executed, double click the new node graph just below the render target previously selected.
baking_graph_double_click.jpg

At the center of the node graph should be visible the generic copy of the render target and an annotation node that stores all the materials with the proper baking ID.
baking_graph_material_ids.jpg

By selecting the generic copy, is possible to fine tune all the settings, like resolution, render passes, kernel settings and so on. Since they are shared with all the other baking render targets, when finished, just select the default Batch rendering script to render all the textures in one go.
Note that the baking camera setting in the generic copy are not automatically transferred to the other baking render targets, the script must to be executed again with different default settings.
I have prepared a little video to better demonstrate the work flow:

https://vimeo.com/150882103
I have tried the script in different scenarios and it seems to work correctly in all of them, but probably I have not catched all the possibility :roll:
Please, let me know of any issue or comment and critics.
Happy baking :)
ciao beppe
Last edited by bepeg4d on Sat Dec 29, 2018 5:48 pm, edited 5 times in total.
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 6225
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Baking Graph with Lua

Postby smicha » Wed Jan 06, 2016 10:41 am

smicha Wed Jan 06, 2016 10:41 am
You are the man, beppe!

PS. Could you please help in improvement of the LUA script? I posted some questions there viewtopic.php?f=73&t=41388
Win7, Modo 10.1, Octane for Modo and Sketchup, nVidia latest, TITAN+3x780 6GB, 2600K, P8P67WS, 32GB, 1350W
SMH10, EK, Airplex_480, SR1_560, 20xNB_PL2, 2xD5, Aquaero 6XT
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3140
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Baking Graph with Lua

Postby bepeg4d » Thu Jan 07, 2016 9:47 am

bepeg4d Thu Jan 07, 2016 9:47 am
Hi,
thanks man :)
yes I could try to have a look at it, it's already on my todo list, but I have to confess that I already have several Lua projects opened that I must to close first, sorry :(
If you are not in a hurry, I will certainly do it sooner or later ;)
ciao beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 6225
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Baking Graph with Lua

Postby smicha » Thu Jan 07, 2016 2:45 pm

smicha Thu Jan 07, 2016 2:45 pm
Thanks. I'll be patient.
Win7, Modo 10.1, Octane for Modo and Sketchup, nVidia latest, TITAN+3x780 6GB, 2600K, P8P67WS, 32GB, 1350W
SMH10, EK, Airplex_480, SR1_560, 20xNB_PL2, 2xD5, Aquaero 6XT
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3140
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Baking Graph with Lua

Postby steven369 » Thu Jan 07, 2016 9:07 pm

steven369 Thu Jan 07, 2016 9:07 pm
Thanks so much ! this is really great :shock:
steven369
Licensed Customer
Licensed Customer
 
Posts: 10
Joined: Sat Jun 06, 2015 9:53 am

Re: Baking Graph with Lua

Postby bepeg4d » Fri Jan 22, 2016 11:46 am

bepeg4d Fri Jan 22, 2016 11:46 am
Hi all,
I have update the first post with a new script to metch to the new OctaneRender™ v3 aplha 4 version with displacement enabled during Baking ;)
Happy GPU rendering :)
ciao beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 6225
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Baking Graph with Lua

Postby bepeg4d » Fri Feb 19, 2016 1:58 pm

bepeg4d Fri Feb 19, 2016 1:58 pm
Hi,
I have revisited the Lua script, you can find the new version here:
viewtopic.php?f=73&t=52754

ciao beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 6225
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Baking Graph with Lua

Postby SamuelAB » Wed Dec 19, 2018 12:38 am

SamuelAB Wed Dec 19, 2018 12:38 am
Very nice to see this script!

I am trying to get it working in Octane for Unity and it does not seem to register my scene.

I am getting the following error:
[string "Baking Graph_3.02.lua"]:281: Cannot get connected attribute via pin.

Baking.jpg


This is likely because my Scene is not an OBJ, but a reference to the Unity Scene. Would it be possible to adapt the script to work with Unity? Or perhaps I am just doing something wrong.

In Unity, my geometry is already split by UVs. So each object is unwrapped on a single UV.

UV.jpg


I am trying to find an efficient way to:
-Assign a unique Bake ID to every single piece of geometry in Unity
-Create a render target in Unity for the Denoised Diffuse channel
-Render these images using the Batch Renderer through Unity
-Create a Unity Material for each rendered map and assign the map to diffuse and emissive textures of the material
-Assign these new materials to the appropriate objects in Unity

Let me know what you think. Thanks!
User avatar
SamuelAB
Licensed Customer
Licensed Customer
 
Posts: 110
Joined: Sun Apr 15, 2012 8:25 pm

Re: Baking Graph with Lua

Postby bepeg4d » Sat Dec 29, 2018 5:51 pm

bepeg4d Sat Dec 29, 2018 5:51 pm
Hi,
I have updated the script to make it working also with v4 in the first post.
The script is designed to work with Octane Standalone, sorry I cannot help with Unity, better to ask in the proper section of the forum:
viewforum.php?f=129
ciao Beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 6225
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 1 guest

Thu Mar 21, 2019 11:46 am [ UTC ]