3
$\begingroup$

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?

$\endgroup$
3
  • 1
    $\begingroup$ Related blender.stackexchange.com/questions/52231/… $\endgroup$ Dec 12, 2018 at 2:15
  • 1
    $\begingroup$ if you ffind out, let me know because thats seems pretty useful. $\endgroup$
    – eromod
    Dec 12, 2018 at 4:15
  • $\begingroup$ @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)) $\endgroup$ Dec 12, 2018 at 14:04

1 Answer 1

1
$\begingroup$

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)
$\endgroup$

This site is temporarily in read-only mode and not accepting new answers.

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