Identify when scene is rendering (Redshift)
-
I'm trying so set up something that will switch between low resolution proxies during interactive sessions and the high resolution model when rendering. We are rendering with Redshift.
What I've got going is based on this: Thread 10877I have added 2 layers to my scene. One containing the proxy objects ("Lyr_PROXY") the other("Lyr_HQ") holding the full resolution models. On a null object there is a python-tag with the following code:
import c4d def main(): global render obj = op.GetObject() status = obj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] ON_list = obj[c4d.ID_USERDATA, 1] #use 1 for the first user data OFF_list = obj[c4d.ID_USERDATA, 2]#use 2 for the second user data if c4d.threading.GeIsMainThread()==False: the_thread = c4d.threading.GeGetCurrentThread() if c4d.threading.IdentifyThread(the_thread) == c4d.THREADTYPE_RENDEREXTERNAL: render = True elif c4d.threading.IdentifyThread(the_thread) == c4d.THREADTYPE_NONE: render = True elif c4d.threading.IdentifyThread(the_thread) == c4d.THREADTYPE_RENDEREDITOR: render = True else: render = False layer_object_root = doc.GetLayerObjectRoot() layers = layer_object_root.GetChildren() setting_proxy = bool(int(not render) * int(status)) setting_hq = bool(int(render) + int(not status)) for layer in layers: if layer.GetName() == "Lyr_PROXY": layer.SetLayerData(doc,{ 'view':setting_proxy, 'render':setting_proxy, 'generators':setting_proxy, 'animation':setting_proxy }) if layer.GetName() == "Lyr_HQ": layer.SetLayerData(doc,{ 'view':setting_hq, 'render':setting_hq, 'generators':setting_hq, 'animation':setting_hq })
This works when doing a bucket render to the pictureviewer or to the redshift renderviewer but not when doing interactive renders in the redshift renderview. It would be nice if this would work aswell but more importantly it also doesn't work when doing commandline renders with deadline. How do I know it's doing a commandline rendering? Or any other way of render with redshift?
I've looked at "4d.CheckIsRunning()" but that doesn't seem to be the answer.Thanks. Bart
-
Hi wen, thanks for reaching out us.
With regard to the question of recognizing when Cinema is running headless I recommend to have a look at GeGetVersionType().
With regard to knowing when RS is in the interactive rendering mode, I recommend to ask directly in the RS forum.
Finally with regard to know if it's rendering with Redshift from PythonTag you can go up to the hosting Object then up to the hosting document and to the RenderData. From here you can check for
c4d.RDATA_RENDERENGINE
and be notified about the rendering engine in use in your offline rendering.Cheers, Riccardo
-
Hi Riccardo,
Thanks for your reply. I cant get c4d.GeGetVersionType() to work the way I expect it. I was thinking of output-ing it to a text object for testing purposes. That should than show me a different number when rendering depending on whether it's in the application or through the commandline. Both return 2.
Furthermore most of the constants I would be checking against don't resolve in R20 but do in R21. Is this command changed significantly in R21? We're still using R20.
-
After posting on the Redshift forum I got some help from one of the admins there. Although he could not help me finding out if an interactive render is running he had a great tip regarding finding if a render is currently running. His suggestion was to check for the MSG_MULTI_RENDERNOTIFICATION and that works really well including when rendering on the commandline.
-
Hi @wen, thanks for the update. Great that you get things sorted out.
Cheers, R
-
@wen I was trying to do the same the past days.
I could'nt figure out how to detect if Redshift IPR is enabled, but I found some relevant RS Ids.The
1038666
command opens the IPR window, but as far as I know there's no way to get the dialog instance to callIsOpen()
The
1036752
CoreMessage is sent during IPR renders, but without any additional parameters (PAR1/PAR2). Not sure if there's something else we can extract from that message.What I ended up doing is adding a bool to my plugin to enable IPR features, but would be good to enable automatically.