Is InitRender called once for each frame of a render?
-
When rendering an animation, is the InitRender method of a Shader plugin called just once at the start of the render, or is it called once at the start of each rendered frame?
-
Hey @rui_mac,
Thank you for reaching out to us. Let me preface my answer with the premise that you are sort of asking the wrong question here.
You can quite easily put a print statement into an
InitRender
method and then see that this method is at least called once per render initlization (at least at first glance). When rendering a document with an animation, this means an initlization occurring at least once per frame.The problem with your question is that you are trying to establish a causality where is none. We do deliberately do not give any guarantees as to how often certain methods are being called by Cinema 4D, as the core of Cinema 4D does change over time. The method is called whenever Cinema 4D must initialize a rendering, as hinted at by the method name and docs. This naturally also includes frames, but there could be cases where Cinema 4D decides not to reinitialize a shader for a given frame N because some special circumstance X is met, and instead just reuses the shader instance from the last frame. More likely to happen is however, that a node is reinitialized much more often than it is obvious from the outside; e.g., you might end up with three calls for frame 1 and one call for the rest of the frames.
So, as hinted at the beginning, you are sort of asking here the wrong question. Yes, Cinema 4D will ask you for each render event to setup your shader. Normally this means for each frame a call, but there might be exceptions. There is not this direct causality "either once per instance or once per frame" you imply. This method is called when Cinema 4D initializes a rendering, we cannot give any guarantees beyond that.
Cheers,
Ferdinand -
Thank you very much, Ferdinand. I understand.