Chaos Corona Forum
Chaos Corona for Cinema 4D => [C4D] I need help! => Topic started by: JPeters on 2024-07-11, 19:04:28
-
Hi guys,
Tried searching around a bit but could not find anything on it.
I am trying to access Multi-Pass via Python, add some Masks with Object ID/ Material ID and unique names.
The script log gives me some pointers on how to address the individual properties but not how to initially enable multipass (it's normally disabled by default in a new scene) and add a new mask.
Any pointers?
Cheers!
-
I wrote something to do exactly that, do you want to do something like this ?
(https://i.imgur.com/cuhZ6Qy.gif)
-
Hi John_Do,
Yes, indeed I want to make something very similar :)
Do you mind sharing a bit of the code or giving me a pointer to where I can find documentation?
-
Hi,
There is no documentation for this stuff, but you can find some hints in the description files stored in the Corona plugin folders ;)
I get back later today with the code and some explanations.
-
I hope it was helpful
-
I hope it was helpful
Nice !
I wrote a quite similar code on my side.
Get and set multi-pass settings
# Access to the corresponding scene hook
mp_settings = doc.FindSceneHook(1037467)
# Enable multipass
if mp_settings[c4d.CORONA_MULTIPASS_ENABLE] == 0:
mp_settings[c4d.CORONA_MULTIPASS_ENABLE] = 1
Get passes list
# Passes are stored under a c4d.GeListHead object
# First we get the scene hook that stores multipass settings
# and the branch for passes
hook = c4d.documents.GetActiveDocument().FindSceneHook(1037467)
branch = hook.GetBranchInfo()
# Then we look for the list head
if branch:
head = [b.get('head') for b in branch if b.get('id') == 1037373]
if head:
head = head[0]
return head
Then you can handle the passes list from the head level or the nodes level depending on your needs.
-
Thank you both very much! I will have a look at the code and see how I can implement it into my plugin :)
@m4drid: That is an extensive code! wow.
I've not come across this before, but what is a Scene Hook exactly?
Cheers!
-
I've not come across this before, but what is a Scene Hook exactly?
Cheers!
Np, let us know what you are cooking ;)
Regarding Scene Hook I don't know ( I'm just hacking my way through Cinema's Python SDK), you have to ask the devs ! But it seems like a way to store specific data at the document level ( multipass, corona nodes ) without parenting / nesting it inside an already existing Cinema 4d object (like c4d.GetWorldContainer() / c4d.SetWorldContainer()). It's specific to C++ plugins.
Some info here :
https://developers.maxon.net/docs/cpp/2024_4_0/class_base_scene_hook.html#af1445d83b18dbfa67d8c663d308dde48
(https://developers.maxon.net/docs/cpp/2024_4_0/class_base_scene_hook.html#af1445d83b18dbfa67d8c663d308dde48)
https://developers.maxon.net/docs/cpp/2024_4_0/class_scene_hook_data.html
(https://developers.maxon.net/docs/cpp/2024_4_0/class_scene_hook_data.html)
-
I've not come across this before, but what is a Scene Hook exactly?
Cheers!
Np, let us know what you are cooking ;)
Sorry for the late reply, slipped my mind :)
Managed to finish my plugin for our artists.
It's a plugin that makes it possible for you to select objects and shaders in a scene and then automatically populate the multi-pass window with masks carrying the same name as the object/shader.
There is also a button to clear the existings masks.
It's very simple in terms of functionality but it saves a ton of work with things like interior scenes etc.
Cheers for the help guys!