2
$\begingroup$

I created a multichannel OpenEXR file by script, everything seems to be working well except for the fact that Blender does not save my file when rendering. This problem is specifically for the multichannel OpenEXR; if I create many simple (not multichannel) OpenEXR files they do get saved in the correct directory.

The node tree that is produced by my script looks like this: enter image description here

And the relevant part of the script, that I use to set up part of this node tree:

def take_picture(index):
    bpy.context.scene.use_nodes = True
    tree = bpy.context.scene.node_tree
    nodes = tree.nodes
    links = tree.links

    # create layer + metadata nodes
    rl = nodes.new('CompositorNodeRLayers')    

    l_node = nodes.new('CompositorNodeValue')
    l_node.label = 'Wavelength'
    l_node.name = 'Lambda'
    l_node.location = 300, 0
    l_node.outputs['Value'].default_value = 5

    # call output exr, create extra output slots
    f = nodes.new('CompositorNodeOutputFile')
    f.label = 'EXR Multichannel'
    f.name = 'OutFile'
    f.format.file_format = 'OPEN_EXR_MULTILAYER' 
    # If I cange this to 'OPEN_EXR', I do obtain my output files in the specified folder.
    f.base_path = "//Rendered images/Test/Img" 

    f.file_slots.new('Lambda')
    f.file_slots.new("image_" + index)

    # Links
    links.new(l_node.outputs['Value'], f.inputs['Lambda'])
    links.new(rl.outputs['Image'], f.inputs['image_'+index])

    # render
    bpy.ops.render.render()

When I run this function for some index specified in my script, it works fine and all nodes are created the way I want them to be, but I don't get any output file..

$\endgroup$
3
$\begingroup$

I found this very useful answer on stackoverflow, worked like a charm for me..

The clue is to include write_still = True explicitly in the render command. Also, unlinke for 1-channel openEXR, the filename is not determined by the name of the terminal of the file output node. Now that I come to think of it, this is in fact logic since the terminals should determine the keys that are included in the exr file header. For 1-channel exr there is only 1 channel, thus only in that case the key can also specify the file name.

My last two lines now look like this:

bpy.data.scenes["Scene"].render.filepath = '//Rendered images/Test/im_%s' % index
bpy.ops.render.render(write_still=True)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.