how to create BaseList2D Renderer node : c++ to python
-
Hello :
I want to create a 3rd-part AOV Node to render Engine
Octane
, Octane teams provide a lillte example in C++ , but unfortunately I only use python and cann't understand and translate it into python version .Can you provide a bare-bone code for this snippets in python ?
Any help will be great
BaseList2D *addAOVnode(BaseList2D *parent, Int32 slotID, Int32 TYPE, Octane::RenderPassId passId, Bool incCnt) { BaseContainer *bc = parent->GetDataInstance(); Int32 pType = bc->GetInt32(AOV_NODE_TYPE); BaseList2D *shd = addOctaneShaderToNode(parent, slotID, ID_OCTANE_AOV_NODE); if(TYPE==AOV_TYPE_COMP_GROUP) { shd->SetName(AOV_GROUP_NAME); } else if(TYPE==AOV_TYPE_COMP_AOV) { shd->SetName(AOV_COMP_NAME); } else if(TYPE==AOV_TYPE_COMP_AOV_LAYER) { shd->SetName(AOV_COMPLAYER_NAME); } else if(TYPE==AOV_TYPE_COLOR_OUT) { shd->SetName(AOV_COLOROUT_NAME); } else if(TYPE==AOV_TYPE_IMAGE_AOV_OUT) { shd->SetName(AOV_IMAGEOUT_NAME); } else if(TYPE==AOV_TYPE_COMP_LIGHTMIXER) { shd->SetName(AOV_IMAGEOUT_NAME); } else if(TYPE==AOV_TYPE_RENDER_AOV_OUT) { shd->SetParameter(DescLevel(AOV_RENDER_PASS_ID), GeData((Int32)passId), DESCFLAGS_SET_0); shd->SetName(AOV_RENDEROUT_NAME+S(":[")+ rPassName(passId)+"]"); } setParameterLong(*shd, AOV_NODE_TYPE, TYPE); if(incCnt) { Int32 cnt = bc->GetInt32(AOV_INPUT_COUNT); setParameterLong(*parent, AOV_INPUT_COUNT, cnt+1); } return shd; }
-
Hi :
I don't think you're going to get the answer you're looking for, the Octane renderer is not a Maxon product, so it's beyond the SDK team's technical support. Therefore, you should contact the Octane development team.
Also, the code you give is incomplete, and partial translation is useless. The Octane renderer has an OSL node, which can be used to create custom nodes in the OSL language.
Finally, it's important to point out that Python is a glue language, and the underlying core code is still written in C and C++. If the Octane renderer is installed, Python cannot drive the Octane renderer without the corresponding API parameters. However, you can use Python to simply change the Octane parameters, such as changing the rendering resolution.
In summary, if the Octane renderer does not have open Python API parameters, then C++ is the only option.
-
Hello @dunhou,
Thank you for reaching out to us. As already pointed out by @x_nerve, your question is unfortunately out of scope of support as stated by our forum guidelines:
-
We cannot provided support for third party libraries or code design that is in direct violation of Cinema's technical requirements (e.g. Cinema 4D's threading restrictions).
-
We cannot provide support for learning either C++, Python, or one of its popular third-party libraries.
You are however more than welcome to seek help from other users here. But the problem is also that translating the code does not make too much sense, because it is littered with things that are not part of our Python API. If OTOY also does provide a Python API for their renderer, then this might be mitigated by it. Find below a translation which exemplifies this by marking missing elements as
???
.I would recommend reaching out to OTOY, as we cannot provide any support for this.
Cheers,
FerdinandC++: BaseList2D *addAOVnode(BaseList2D *parent, Int32 slotID, Int32 TYPE, Octane::RenderPassId passId, Bool incCnt) { BaseContainer *bc = parent->GetDataInstance(); Int32 pType = bc->GetInt32(AOV_NODE_TYPE); BaseList2D *shd = addOctaneShaderToNode(parent, slotID, ID_OCTANE_AOV_NODE); if(TYPE==AOV_TYPE_COMP_GROUP) { shd->SetName(AOV_GROUP_NAME); } else if(TYPE==AOV_TYPE_COMP_AOV) { shd->SetName(AOV_COMP_NAME); } else if(TYPE==AOV_TYPE_COMP_AOV_LAYER) { shd->SetName(AOV_COMPLAYER_NAME); } else if(TYPE==AOV_TYPE_COLOR_OUT) { shd->SetName(AOV_COLOROUT_NAME); } else if(TYPE==AOV_TYPE_IMAGE_AOV_OUT) { shd->SetName(AOV_IMAGEOUT_NAME); } else if(TYPE==AOV_TYPE_COMP_LIGHTMIXER) { shd->SetName(AOV_IMAGEOUT_NAME); } else if(TYPE==AOV_TYPE_RENDER_AOV_OUT) { shd->SetParameter(DescLevel(AOV_RENDER_PASS_ID), GeData((Int32)passId), DESCFLAGS_SET_0); shd->SetName(AOV_RENDEROUT_NAME+S(":[")+ rPassName(passId)+"]"); } setParameterLong(*shd, AOV_NODE_TYPE, TYPE); if(incCnt) { Int32 cnt = bc->GetInt32(AOV_INPUT_COUNT); setParameterLong(*parent, AOV_INPUT_COUNT, cnt+1); } return shd; } --- snip ------------------------------------------------------------------------------------------- Python approximation: AddAOVnode(parent: c4d.BaseList2D, slotID: int, TYPE: int, passId: ???, incCnt: bool) -> c4d.BaseList2D: """ """ bc: c4d.BaseContainer = parent.GetDataInstance() pType: int = bc[???] shd: c4d.BaseList2D = ???(parent, slotID, ???) if TYPE == ???: shd.SetName(???) ... elif TYPE == ???: shd.SetParameter(???, passId, DESCFLAGS_SET_NONE) shd.SetName(f"{???}[{???(passId)}]") ???(shd, ???, TYPE) if incCnt: cnt: int = bc.GetInt32(???) ???(parent, ???, cnt + 1) return shd
-
-
Yes , I know exactlly what you mean , but unfortunally , Octane form and Octane support is not good as this PluginCafe . Some post I even cannot post a topic . I don't know what lead this happened , but it does .
Actually , I post it and ask , this is all they reply , not a example or any explain , even not what I ask for python , by the way , I try to add a aov node like this C++ ( for the part I can read ) , it does worked for something , like insert a node to aov node gragh an connect or something , I think it also like
c4d.BaseMaterial
structure or something like that >-- Renderer -- AOV out node -- Beauty AOV
So I can do a little work , so I what to know how this code means . I know that Maxon would not support this
-
Thanks for that , as I metion above , Otoy didn't providing support . And they even didn't reply the topic
And this is all I want , I just want to know what this code happend and to move on .
I will still try to ask help for Otoy , thanks for your help
-
I find a way to read aovs and render container , if I had some times I will post a create
Read Octane Post
from typing import Optional import c4d SET_RENDERAOV_IN_CNT=3700 SET_RENDERAOV_INPUT_0=3740 RNDAOV_TYPE=995 RNDAOV_ENABLED=994 doc: c4d.documents.BaseDocument # The active document op: Optional[c4d.BaseObject] # The active object, None if unselected c4d.CallCommand(13957) #clear console def main() -> None: rdata = doc.GetActiveRenderData() vpost = rdata.GetFirstVideoPost() OctaneRender_ID = 1029525 octVp=None # rdata[c4d.RDATA_RENDERENGINE] = OctaneRender_ID while vpost: print(vpost) if vpost.GetName() == "Octane Renderer": octVp=vpost vpost = vpost.GetNext() if octVp: aovCnt = octVp[SET_RENDERAOV_IN_CNT] print ("--- OCTANERENDER FOUND ---") print(octVp) print ("Buffer:",octVp[1010]) print ("Color space:",octVp[1028]) print ("AOV count:",aovCnt) for i in range(0,aovCnt): aov = octVp[SET_RENDERAOV_INPUT_0+i] enabled = aov[RNDAOV_ENABLED] type = aov[RNDAOV_TYPE] print ("AOV1:",aov," type:",type," enabled:", enabled) if type==185: # cryptomatte print (" crypto_type:",aov[1821]) if type==255: #z-depth AOV print (" z-depth max:",aov[3392]," env.depth:",aov[3397]) if __name__ == '__main__': main()