# Generating RGB,EXR or Both on demand using Blender Python

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?

• Unfortunately there is no way to disable the default output (if that's your question) -> Disable default animation output when using "File output" nodes. Oct 19, 2021 at 11:26
• Ohh ... that's bad. Anyway, thank you for your help. Oct 19, 2021 at 12:45
• No problem @Sourabh. Suggest set the default output to jpg and remove the file if necessary using python. Oct 19, 2021 at 13:51
• what happens if you set the File Output node's path to the name of the exr file? 2 files, an error, or just 1? Oct 20, 2021 at 20:17