I am trying to render depth maps and surface Normals using Cycles and store the results in OpenEXR format using nodes. I set up the nodes as follow using Blender's Python API:
#blenderClass.py import importlib class Blender(object): def __init__(self): self.bpy = importlib.import_module("bpy") self.scene = self.bpy.context.scene self.scene.render.use_sequencer = False self.scene.display_settings.display_device = 'sRGB' self.scene.view_settings.view_transform = 'Raw' self.scene.sequencer_colorspace_settings.name = 'Raw' self.scene.render.engine = 'CYCLES' self.scene.use_nodes = True self.setupRenderNodes() def setupRenderNodes(self): for node in self.scene.node_tree.nodes: self.scene.node_tree.nodes.remove(node) renderNode = self.scene.node_tree.nodes.new('CompositorNodeRLayers') # Depth map self.depthOutputNode = self.scene.node_tree.nodes.new('CompositorNodeOutputFile') self.depthOutputNode.format.file_format = 'OPEN_EXR' self.depthOutputNode.format.color_depth = '32' self.depthOutputNode.format.color_mode = 'RGB' self.depthOutputNode.format.exr_codec = 'ZIP' self.depthOutputNode.base_path = 'somePath/' self.depthOutputNode.file_slots[0].path = 'fileNameDepth#' # Link self.scene.node_tree.links.new(renderNode.outputs[2], self.depthOutputNode.inputs[0]) def render(self, objPath): self.bpy.ops.import_scene.obj(filepath=objPath) self.bpy.ops.render.render(write_still=True)
#main.py from multiprocessing import Process import blenderClass import Blender blender = Blender() objPaths = ['obj1.obj', 'obj2.obj', 'obj3.obj', 'obj4.obj'] procList = [] for path in objPaths: proc = Process(target=blender.render, kwargs={'objPath': path}) procList.append(proc) proc.start() for job in procList: job.join()
The problem is when I do bpy.ops.render.render(write_still=True) Blender freezes and the results are not saved on disk. However, if I change OPEN_EXR_MULTILAYER and OPEN_EXR to PNG and change the color_depth to '16' everything works and I get the rendering results on disk. Note that I do not change any of my rendering engine settings like tile size, resolution etc. Does anyone know why Blender freezes and the rendering results are not on disk when using OpenEXR?
The strange thing is everything works normally when running Blender with GUI and setup the nodes and rendering engine the same way. It would be also useful if someone can try this and let me know if things work fine on their side.
I'm not sure if this has something to do with the problem that I'm facing but I have compiled Blender manually and import it as a module in the Python installed on my machine. Here are the CMake settings I used to compile Blender 2.79b from source:
cmake blender \ -DCMAKE_INSTALL_PREFIX=/usr/lib/python3/dist-packages \ -DWITH_INSTALL_PORTABLE=OFF \ -DWITH_PYTHON_INSTALL=OFF \ -DWITH_PYTHON_MODULE=ON \ -DPYTHON_SITE_PACKAGES=/usr/lib/python3/dist-packages \ -DPYTHON_VERSION=3.5 \ -DWITH_OPENAL=ON \ -DWITH_CODEC_AVI=ON \ -DWITH_MOD_OCEANSIM=ON \ -DWITH_CODEC_FFMPEG=ON \ -DWITH_SYSTEM_GLEW=ON \ -DWITH_FFTW3=ON \ -DWITH_OPENCOLORIO=ON \ -DWITH_GAMEENGINE=OFF \ -DWITH_PLAYER=OFF
Update: I experience the same behavior with Blender 2.78 and 2.79, compiled with the same exact settings above.