I am trying to generate a python script for rendering RGB and/or an EXR file(for getting the mist pass) for spherical images using blender.
So I have a scene and I am using the cycles rendering engine. I want to save the OpenExr file and/or the RGB file based on the input that the user gives (for which I am using a JSON file).
For the mist pass I am using a setup similar to the following link: Getting the depth of every pixel to the center of projection of the camera in Blender
I am using the following lines of code for creating and saving the renders.
bpy.context.scene.render.filepath=output_path+str(i)
bpy.ops.render.render(use_viewport=True,write_still=True)
However, the above lines of code save both the RGB image as well as the EXR file. In order to render just the RGB images I have used the following in addition to the above lines of code and that works well:
bpy.context.scene.use_nodes = False
However, I am not able to generate just the OpenEXR file. Simply using the following also didn't help :
bpy.ops.render.render(write_still=True)
Can someone guide me with this and/or suggest a better way for the same?