I made a fork of the awesome CYCLES render engine. I wonder, can I package my fork as an add-on for blender?
I know that there are many alternative render engines for blender (e.g. LuxCoreRender). LuxCoreRender can be installed as an add-on. Can I do the same?
Not easily, the way Cycles is integrated requires access to Blender APIs that are not available to addons. In principle it is possible to do all the same things through the Python API, but that would require rewriting a lot of the Blender to Cycles conversion code.
brecht, what do you think about the following idea.
Cycles “add-on”, I mean cycles RenderEngine implementation in python, imports the “_cycles” module. This module is generated by blender.exe on every blender start up.
Can I build _cycles as a .pyd dynamic library. And import it in my CustomCyclesRenderEngine?
Actually, I did it. Now I have CustomCycles.pyd, and I can import it in my add-on. But… I have problems with the RNA access. When I pass scene.as_pointer() to C++ it doesn’t have scene.cycles. And I do not know why.
Please, could you answer this question? And is the idea feasible?
No, that doesn’t work around the issues that I mentioned. _cycles is part of Blender itself and uses non-public Blender APIs, and separating it is where the difficulty is.
I know that _cycles is part of Blender and uses Blender API.
I have built _cycles as .pyd. More precisely, I slightly changed blender_python.cpp code and cmake lists, so this _cycles.pyd has all blender API inside and it is importable in python.
I don’t think that works. Duplicating the Blender API inside _cycles.pyd may work for some things but in general it will not interact correctly with Blender.
I think these are just nodes that got renamed, they should all be there. Still for interactive viewport rendering going through XML is not really an option, you need to talk to the API directly.
One way or another, I think making this separation requires quite a lot of work. Either rewriting the Cycles export code to be more Python based like other external renderers that integrate into Blender, or supporting an official C++ Blender API that can be shared with official Cycles. Both would likely be months of work.