Skip to content

Instantly share code, notes, and snippets.

@sambler
Last active June 7, 2021 07:47
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sambler/7542f7779fbff6499049c36d740f0455 to your computer and use it in GitHub Desktop.
Save sambler/7542f7779fbff6499049c36d740f0455 to your computer and use it in GitHub Desktop.
Setup multi scene rendering
# made in answer to http://blender.stackexchange.com/q/74086/935
import bpy
master_render_scene_name = 'Multi_render'
base_path = '//renders/'
if master_render_scene_name not in bpy.data.scenes:
bpy.data.scenes.new(name=master_render_scene_name)
masterScene = bpy.data.scenes[master_render_scene_name]
masterScene.use_nodes = True
masterNodeTree = masterScene.node_tree
for n in masterNodeTree.nodes:
masterNodeTree.nodes.remove(n)
fileNode = masterNodeTree.nodes.new('CompositorNodeOutputFile')
fileNode.base_path = base_path
fileNode.format.file_format = 'PNG'
fileNode.format.color_mode = 'RGBA'
for s in fileNode.file_slots:
fileNode.file_slots.remove(fileNode.inputs[0])
nspacing = 40
nx = (len(bpy.data.scenes)*nspacing)/2
for scn in bpy.data.scenes:
if scn.name == master_render_scene_name:
continue
sp = scn.render.filepath.replace(base_path,'')
fs = fileNode.file_slots.new(sp)
rl = masterNodeTree.nodes.new('CompositorNodeRLayers')
rl.scene = scn
rl.hide = True
rl.location.x = -300
rl.location.y = nx
nx -= nspacing
masterNodeTree.links.new(rl.outputs['Image'], fs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment