Page 1 of 1

Baking Graph with Lua

PostPosted: Wed Jan 06, 2016 10:35 am
by bepeg4d
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 323 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 571 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 559 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:
[vimeo]http://www.vimeo.com/150882103[/vimeo]
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

Re: Baking Graph with Lua

PostPosted: Wed Jan 06, 2016 10:41 am
by smicha
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

Re: Baking Graph with Lua

PostPosted: Thu Jan 07, 2016 9:47 am
by bepeg4d
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

Re: Baking Graph with Lua

PostPosted: Thu Jan 07, 2016 2:45 pm
by smicha
Thanks. I'll be patient.

Re: Baking Graph with Lua

PostPosted: Thu Jan 07, 2016 9:07 pm
by steven369
Thanks so much ! this is really great :shock:

Re: Baking Graph with Lua

PostPosted: Fri Jan 22, 2016 11:46 am
by bepeg4d
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

Re: Baking Graph with Lua

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

ciao beppe

Re: Baking Graph with Lua

PostPosted: Wed Dec 19, 2018 12:38 am
by SamuelAB
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!

Re: Baking Graph with Lua

PostPosted: Sat Dec 29, 2018 5:51 pm
by bepeg4d
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