I'm working on a script that divides rendering into parts using borders and then renders random selection of parts.

An example script looks like that (it actually renders all parts):

import bpy

scene = bpy.context.scene

scene.render.tile_x = 16
scene.render.tile_y = 16
scene.render.resolution_x = 800
scene.render.resolution_y = 600
scene.render.resolution_percentage = 100
scene.render.use_border = True
scene.render.use_crop_to_border = True

n = 4
m = 4

cnt = 0
for i in [x * 1.0/n for x in range(n)]:
    for j in [x * 1.0/m for x in range(m)]:
        scene.render.border_max_x = i + 1.0/n
        scene.render.border_min_x = i
        scene.render.border_min_y = j
        scene.render.border_max_y = j + 1.0/m
        cnt += 1
        scene.render.filepath = "res_{}.png".format(cnt)

The script works as expected but I have noticed time penalties by rendering this way. From logs I can see that the bpy.ops.render.render() command is "synchronizing" and "updating" the scene every time executed.

Is there a way to do a scene preparation for rendering once?

  • $\begingroup$ Does it help to add empty and go to local mode before running the script ? $\endgroup$
    – JuhaW
    Feb 29, 2016 at 15:40
  • 3
    $\begingroup$ I'm not sure what engine you are using, but have you tried 'Save Buffers' & / OR 'Cache BVH'? $\endgroup$
    – Rick Riggs
    Feb 29, 2016 at 16:22

1 Answer 1



Not really an answer

even though the code below looks like a significant rewrite, it's mostly just for generic OS use... What I had noticed running through the script below (which is likely causing the sync & updating issues you're referring to) is that the renders are generated based on the segmented window throughout the entire animation sequence, then moving to the next segmented window and running through the entire animation sequence again. As such any interpolation of animation & raytracing, etc will be recalculated not only frame by frame, but each segment frame by frame.

If you watch the console while running this you should see what I mean.

This script:
Verifies, the active blend file is saved
Generates a folder for the active blend file where it is saved
Generates sub folders for each scene
Renders for each scene
All naming is based on names used in blend file (blend file name, scene names, object names)
For different render options change the true/false option at ~line 52 & blender menu options

import bpy
import os

filepath = bpy.data.filepath
osdir = os.path.dirname(filepath)
osfile = os.path.basename(filepath.replace('.blend', ''))

selected = bpy.context.selected_objects

list_of_all_scenes = bpy.data.scenes
scene = bpy.context.scene

n = 8
m = 8

if bpy.data.is_saved:
    for scn in list_of_all_scenes:
        bpy.context.screen.scene = scn
        if not os.path.isdir(os.path.join(osdir, osfile, scn.name)):
            os.makedirs(os.path.join(osdir, osfile, scn.name))
    for scn in list_of_all_scenes:
        bpy.context.screen.scene = scn
        cnt = 0
        scn.render.tile_x = 16
        scn.render.tile_y = 16
        scn.render.resolution_x = 800
        scn.render.resolution_y = 600
        scn.render.resolution_percentage = 100
        scn.render.use_border = True
        scn.render.use_crop_to_border = True
        for i in [x * 1.0/n for x in range(n)]:
            for j in [x * 1.0/m for x in range(m)]:
                scn.render.border_max_x = i + 1.0/n
                scn.render.border_min_x = i
                scn.render.border_min_y = j
                scn.render.border_max_y = j + 1.0/m
                cnt += 1               
                bpy.context.screen.scene.render.filepath = os.path.join(osdir, osfile, scn.name, scn.name + "_cnt(" + str(cnt) + ")_frame(" + str(scn.frame_current) + ")_auto")
                bpy.ops.render.render(animation=False, write_still=True, use_viewport=False, layer="", scene="" )

You must log in to answer this question.

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