I am using Cycles with OptiX to render a lot of different camera angles of the same scene.
Using code like:
for camera in cameras: # Set camera location to x,y,z etc # Render the scene bpy.ops.render.render()
Works for me, but I have an issue that each render re-initializes the OptiX renderer and re uploads all the data. In my case this is a significant amount of data. I have found that setting a multi camera works for this:
bFirstCamera = True for camera in cameras: cameraPosition = camera.position # Create the camera object camObj = bpy.data.objects.new("Camera_" + camera.name, camData) camObj.location = (cameraPosition, cameraPosition, cameraPosition) bpy.context.scene.collection.objects.link(camObj) # Get the first render view and override it renderView = bpy.context.scene.render.views if bFirstCamera == False: renderView = bpy.context.scene.render.views.new(camera.name) else: bpy.context.scene.camera = camObj # Set the camera in the render view renderView.name = camera.name renderView.camera_suffix = camera.name renderView.file_suffix = camera.name renderView.use = True bFirstCamera = False # Render the scene with all cameras at once bpy.ops.render.render()
This also works and is much faster than doing them one by one. However, the compositing stage does not run until all the cameras are rendered, which uses a lot of memory (there are a lot of views) and another image process (outside of Blender) that is waiting on the results cannot start processing the images until all of them are done.
Is there a way I can:
- Flag "do compositing after each render view"?
- Or, Keep optiX scene in memory between renders if no change?
- Or, Some other Blender render view setup?