LuxCore plugin logic

Discussion related to the LuxCore functionality, implementations and API.
Post Reply
User avatar
Egert_Kanep
Posts: 237
Joined: Tue Mar 13, 2018 10:34 am

LuxCore plugin logic

Post by Egert_Kanep »

There has been some discussion on Discord about other exporters for LuxCoreRender, so I thought maybe in the future I'll also give it a try. I'm a total beginner in this coding stuff and get chill for just looking at all that text, so I thought maybe this could help me better understand some things.

Mainly what I am interested in is the logic of exporter. My idea, maybe it already works this way, is that my compositing software will send 3d scene and material info(as text os something) to LuxCore, which is running on the background and the Lux sends the rendered image back to compositing software. If it already works in similar fashion I guess I'll go dive into blender's plugin to see the logic behind this. Would my method need some kind of GUI'less/commandline version of LuxCore?

I'm not currently working on this yet, but maybe the upcomig month I'll start looking more into it. All thoughts are welcome :D
User avatar
nigec
Posts: 141
Joined: Mon Mar 11, 2019 8:50 am

Re: LuxCore plugin logic

Post by nigec »

look at the Freecad exporter that is about the easiest to follow, unfortunately it doesn't seem to do textures (but I maybe missing something) it does color materials which is a start.
The first thing would be getting it exporting to Luxcore rather than Luxrender, then maybe cfg and scn's rather than lxs
This is what I intend to do
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: LuxCore plugin logic

Post by B.Y.O.B. »

Egert_Kanep wrote: Thu Apr 04, 2019 9:03 pm Mainly what I am interested in is the logic of exporter. My idea, maybe it already works this way, is that my compositing software will send 3d scene and material info(as text os something) to LuxCore, which is running on the background and the Lux sends the rendered image back to compositing software.
Do you mean like a daemon process that's always running? That's possible, but not how the current plugins work.

The Blender addon uses pyluxcore, which is a Python interface for LuxCore.
It works like this:
I create a new LuxCore scene with

Code: Select all

luxcore_scene = pyluxcore.Scene()
This calls the Python API of LuxCore, which then calls the underlying C++ code and creates a Scene instance and gives the control back to Python.
Then I can for example convert a mesh:

Code: Select all

faces = mesh.tessfaces[0].as_pointer()
luxcore_scene.DefineBlenderMesh(name, len(mesh.tessfaces), faces ...)
Again, the Python API calls corresponding C++ code, which is executed. After the C++ function is done, the scene contains the converted mesh, and we jump out of the C++ code back to Python and execute the next lines of Python.

So a lot of it is happening on demand, there's no LuxCore process running all the time.
When the rendering is started, LuxCore creates the required threads from C++, so you don't care about that from the Python side. The rendering runs asynchronically, meaning your Python interpreter continues executing your code while LuxCore renders. Usually you create a loop for this where every x milliseconds you update the statistics, check if the user wants to end the render, check if any halt conditions are met - and of course you can retrieve the rendered output through a Python API function.

Does this description help? If you have further questions, ask away :)
User avatar
nigec
Posts: 141
Joined: Mon Mar 11, 2019 8:50 am

Re: LuxCore plugin logic

Post by nigec »

this was a big help for me which B.Y.O.B. linked
viewtopic.php?f=4&t=371&p=4098&hilit=Co ... tput#p4099
Post Reply