0
$\begingroup$

I'm using Blender's compositor to build the final images based on several things including the 3D render output. Nothing special....

Normally, the 3D render output in the compositor is always the last one that has been rendered. When I'm clicking around in the time line, my script and a frame-change handler there is altering several things in the compositor as well as in the 3D scene. While the 3D viewport does reflect the changes, they are not forwarded to the compositor, since the scene is only preview-rendered. This is a bit annoying for my special use-case.

So is there a way to have Blender to re-render the 3D-scene automatically whenever the frame number is being changed? I already tried bpy.ops.render.render(write_still=False) from within the frame-change handler, which is apparently a bad idea since it crashes Blender (I guess due to recursive calling).

Thanks for any hints, Mario

Update: In the properties of the compositor in the "Options"-tab under "Performance" there is an "Auto Render" option. Would be nice if that is working. However, this does have no effect when the 3D scene is changed from within the script. It does have an effect, when I manually edit objects. But maybe it is somehow possible to trigger some sort of scene-change event from the script???

$\endgroup$

1 Answer 1

0
$\begingroup$

Not sure whether this is a good solution, but I'm doing this now by using bpy.ops.render.render() in junction with a recursion-detection mechanism within the frame-change handler. This is working as follows:

# Initialization code
# Declare a global flag showing whether the frame-change handler has been
# called. Initialized with False, hence marking a "not-called" condition
# by default.
recursive_change = False

# frame change handler
def on_frame_changed(Scene):

    # For Python-reasons we have to re-declare the flag as "global".
    global recursive_change

    # Skip all tasks in case we have already been called before.
    if not recursive_change:
        # Mark that we have been called.
        recursive_change = True

        # Do all the work that needs to be done.
        # ....

        # Trigger rendering
        bpy.ops.render.render()

        # Mark that we have finished.
        recursive_change = False

Thus far it's working like a charm....

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .