3

I'm trying to render an animation simultaneously from 32 points of view and integrate the result in a composed animation.

I followed this answer: How to create a render layer in blender python

and this one: How to combine renders from multiple cameras

However using:

basescene=bpy.context.screen.scene
for i in Hs:
 for j in Ws:
   bpy.context.screen.scene=basescene
   bpy.ops.scene.new(type='LINK_OBJECTS')       
   newscene=bpy.context.screen.scene
   newscene.name='scene_h_'+ str(i)+'_w_'+str(j)
   new_render_layer =  scene.render.layers.new('rl_h_'+ str(i)+'_w_'+str(j)) 
   newscene.render.layers.active=new_render_layer

Each scene render.layers.active is equal to:

 bpy.data.scenes['scene_h_0_w_4'].render.layers["RenderLayer"]

Or in other words, whatever scene is selected the following is true:

bpy.context.scene.render.layers.active.name == "RenderLayer"

Also the scenes would always miss only the last render layer created

 e.g.   rl_h_0_w_4 not in scene_h_0_w_4 but scene_h_0_w_4 in scene_h_0_w_5

How can I associate each scene to a different render layer and compose them in the final scene?

  • 1
    Related https://blender.stackexchange.com/questions/52231/rendering-a-stereoscopic-image-in-blender-2-77/ – Duarte Farrajota Ramos Dec 12 '18 at 02:15
  • 1
    if you ffind out, let me know because thats seems pretty useful. – eromod Dec 12 '18 at 04:15
  • @eromod I found the error... This line
    new_render_layer =  scene.render.layers.new('rl_h_'+ str(i)+'_w_'+str(j))
    

    has a typo. Should be

    new_render_layer = newscene.render.layers.new('rl_h_'+ str(i)+'w'+str(j))

    – Dimitri Ognibene Dec 12 '18 at 14:04

1 Answers1

1

Actually there was a typo. The following script creates a new scene and a new render layer making it the active one for that scene

for j in range(N_PERSP_x):
   bpy.context.screen.scene=basescene
   bpy.ops.scene.new(type='LINK_OBJECTS')       
   newscene=bpy.context.screen.scene
   bpy.context.screen.scene.name='scene_h_'+ str(j)+'_w_'+str(j)
   new_render_layer =  newscene.render.layers.new('rl_h_'+ str(j)+'_w_'+str(j))        
   newscene.render.layers.active = new_render_layer

You can check the results with:

for scene in bpy.data.scenes:
   print(scene.name,scene.render.layers.active.name)